From 9e8793d1b1834f77d7aa7c17acce74dff6d795f4 Mon Sep 17 00:00:00 2001 From: Srinath Narayanan Date: Wed, 11 Nov 2020 11:31:07 -0800 Subject: [PATCH] Moved constants --- src/Common/Constants.ts | 5 ----- src/Explorer/Tree/Collection.ts | 7 +++++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Common/Constants.ts b/src/Common/Constants.ts index 0886baa1b..a7b50d6f6 100644 --- a/src/Common/Constants.ts +++ b/src/Common/Constants.ts @@ -437,8 +437,3 @@ export class TerminalQueryParams { public static readonly SubscriptionId = "subscriptionId"; public static readonly TerminalEndpoint = "terminalEndpoint"; } - -export class LoadOfferRetry { - public static readonly MaxRetries = 5; - public static readonly RetryAfterMilliSeconds = 5000; -} diff --git a/src/Explorer/Tree/Collection.ts b/src/Explorer/Tree/Collection.ts index 8e93ce307..b3febd035 100644 --- a/src/Explorer/Tree/Collection.ts +++ b/src/Explorer/Tree/Collection.ts @@ -41,8 +41,11 @@ import { userContext } from "../../UserContext"; import TabsBase from "../Tabs/TabsBase"; import { fetchPortalNotifications } from "../../Common/PortalNotifications"; import { getErrorMessage, getErrorStack } from "../../Common/ErrorHandlingUtils"; +import promiseRetry from "p-retry"; export default class Collection implements ViewModels.Collection { + private static readonly LoadOfferMaxRetries = 5; + private static readonly LoadOfferRetryAfterMilliSeconds = 5000; public nodeKind: string; public container: Explorer; public self: string; @@ -1333,11 +1336,11 @@ export default class Collection implements ViewModels.Collection { public async loadAutopilotOfferWithRetry(): Promise { let retryCount = 0; - while (retryCount < Constants.LoadOfferRetry.MaxRetries) { + while (retryCount < Collection.LoadOfferMaxRetries) { if (this.offer().content.offerAutopilotSettings) { return this.offer(); } else { - await new Promise(resolve => setTimeout(resolve, Constants.LoadOfferRetry.RetryAfterMilliSeconds)); + await new Promise(resolve => setTimeout(resolve, Collection.LoadOfferRetryAfterMilliSeconds)); await this.loadOffer(); } retryCount++;