From 356cbe1e93de638e26a9c3e3d7f1ddc292dde73f Mon Sep 17 00:00:00 2001 From: Chris Whitten Date: Tue, 5 Feb 2019 16:11:18 -0800 Subject: [PATCH 1/4] Fixed an issue where pollingInterval was undefined --- src/directLine.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/directLine.ts b/src/directLine.ts index 92af2370c..3dee461fe 100644 --- a/src/directLine.ts +++ b/src/directLine.ts @@ -439,7 +439,7 @@ export class DirectLine implements IBotConnection { if (options.pollingInterval && interval < POLLING_INTERVAL_LOWER_BOUND) { console.warn(`DirectLineJS: provided pollingInterval (${options.pollingInterval}) is under lower bound (200ms), using default of 1000ms`); - } else { + } else if (options.pollingInterval) { this.pollingInterval = options.pollingInterval; } From 8d67a94608abc0a5f434c2543ad1dce05a5dc281 Mon Sep 17 00:00:00 2001 From: William Wong Date: Tue, 5 Feb 2019 16:19:48 -0800 Subject: [PATCH 2/4] Update src/directLine.ts Co-Authored-By: cwhitten --- src/directLine.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/directLine.ts b/src/directLine.ts index 3dee461fe..4766ed23b 100644 --- a/src/directLine.ts +++ b/src/directLine.ts @@ -437,7 +437,15 @@ export class DirectLine implements IBotConnection { const interval = Math.min(~~options.pollingInterval, POLLING_INTERVAL_LOWER_BOUND); - if (options.pollingInterval && interval < POLLING_INTERVAL_LOWER_BOUND) { + if (options.pollingInterval && typeof options.pollingInterval === 'number') { + const interval = Math.min(~~options.pollingInterval, POLLING_INTERVAL_LOWER_BOUND); + + if (interval < POLLING_INTERVAL_LOWER_BOUND) { + console.warn(`DirectLineJS: provided pollingInterval (${options.pollingInterval}) is under lower bound (200ms), using default of 1000ms`); + } else { + this.pollingInterval = options.pollingInterval; + } + } console.warn(`DirectLineJS: provided pollingInterval (${options.pollingInterval}) is under lower bound (200ms), using default of 1000ms`); } else if (options.pollingInterval) { this.pollingInterval = options.pollingInterval; From a1b9071db783c3177cb45495f1f784339901939f Mon Sep 17 00:00:00 2001 From: Chris Whitten Date: Tue, 5 Feb 2019 16:24:31 -0800 Subject: [PATCH 3/4] Revert to original diff --- src/directLine.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/directLine.ts b/src/directLine.ts index 4766ed23b..3dee461fe 100644 --- a/src/directLine.ts +++ b/src/directLine.ts @@ -437,15 +437,7 @@ export class DirectLine implements IBotConnection { const interval = Math.min(~~options.pollingInterval, POLLING_INTERVAL_LOWER_BOUND); - if (options.pollingInterval && typeof options.pollingInterval === 'number') { - const interval = Math.min(~~options.pollingInterval, POLLING_INTERVAL_LOWER_BOUND); - - if (interval < POLLING_INTERVAL_LOWER_BOUND) { - console.warn(`DirectLineJS: provided pollingInterval (${options.pollingInterval}) is under lower bound (200ms), using default of 1000ms`); - } else { - this.pollingInterval = options.pollingInterval; - } - } + if (options.pollingInterval && interval < POLLING_INTERVAL_LOWER_BOUND) { console.warn(`DirectLineJS: provided pollingInterval (${options.pollingInterval}) is under lower bound (200ms), using default of 1000ms`); } else if (options.pollingInterval) { this.pollingInterval = options.pollingInterval; From be135120d6a3cdf9ce479aff6964989e7f62a9b6 Mon Sep 17 00:00:00 2001 From: William Wong Date: Tue, 5 Feb 2019 16:52:34 -0800 Subject: [PATCH 4/4] Refactoring logic --- src/directLine.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/directLine.ts b/src/directLine.ts index 3dee461fe..3f867554a 100644 --- a/src/directLine.ts +++ b/src/directLine.ts @@ -435,12 +435,12 @@ export class DirectLine implements IBotConnection { this._botAgent = this.getBotAgent(options.botAgent); - const interval = Math.min(~~options.pollingInterval, POLLING_INTERVAL_LOWER_BOUND); + const parsedPollingInterval = ~~options.pollingInterval; - if (options.pollingInterval && interval < POLLING_INTERVAL_LOWER_BOUND) { - console.warn(`DirectLineJS: provided pollingInterval (${options.pollingInterval}) is under lower bound (200ms), using default of 1000ms`); - } else if (options.pollingInterval) { - this.pollingInterval = options.pollingInterval; + if (parsedPollingInterval < POLLING_INTERVAL_LOWER_BOUND) { + console.warn(`DirectLineJS: provided pollingInterval (${ options.pollingInterval }) is under lower bound (200ms), using default of 1000ms`); + } else { + this.pollingInterval = parsedPollingInterval; } this.expiredTokenExhaustion = this.setConnectionStatusFallback(