From 5b9d63cb5500a0e67270efc49c8bfd923585c3dd Mon Sep 17 00:00:00 2001 From: nick-delirium Date: Wed, 4 Oct 2023 10:39:11 +0200 Subject: [PATCH] fix(tracker): some fixes for assist --- tracker/tracker-assist/CHANGELOG.md | 4 +++ tracker/tracker-assist/src/Assist.ts | 45 ++++++++++++++-------------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/tracker/tracker-assist/CHANGELOG.md b/tracker/tracker-assist/CHANGELOG.md index c25146776..275a1f026 100644 --- a/tracker/tracker-assist/CHANGELOG.md +++ b/tracker/tracker-assist/CHANGELOG.md @@ -1,3 +1,7 @@ +## 6.0.1 + +- few small fixes for reconnects + ## 6.0.0 - added support for multi tab assist session diff --git a/tracker/tracker-assist/src/Assist.ts b/tracker/tracker-assist/src/Assist.ts index 0e6093edd..4714022cf 100644 --- a/tracker/tracker-assist/src/Assist.ts +++ b/tracker/tracker-assist/src/Assist.ts @@ -279,16 +279,18 @@ export default class Assist { onDisconnect: this.options.onAgentConnect?.(info), agentInfo: info, // TODO ? } - this.assistDemandedRestart = true - this.app.stop() - setTimeout(() => { - this.app.start().then(() => { this.assistDemandedRestart = false }) - .then(() => { + if (this.app.active()) { + this.assistDemandedRestart = true + this.app.stop() + setTimeout(() => { + this.app.start().then(() => { this.assistDemandedRestart = false }) + .then(() => { this.remoteControl?.reconnect([id,]) - }) - .catch(e => app.debug.error(e)) - // TODO: check if it's needed; basically allowing some time for the app to finish everything before starting again - }, 500) + }) + .catch(e => app.debug.error(e)) + // TODO: check if it's needed; basically allowing some time for the app to finish everything before starting again + }, 400) + } }) socket.on('AGENTS_CONNECTED', (ids: string[]) => { ids.forEach(id =>{ @@ -298,17 +300,18 @@ export default class Assist { onDisconnect: this.options.onAgentConnect?.(agentInfo), } }) - this.assistDemandedRestart = true - this.app.stop() - setTimeout(() => { - this.app.start().then(() => { this.assistDemandedRestart = false }) - .then(() => { - this.remoteControl?.reconnect(ids) - }) - .catch(e => app.debug.error(e)) - // TODO: check if it's needed; basically allowing some time for the app to finish everything before starting again - }, 500) - + if (this.app.active()) { + this.assistDemandedRestart = true + this.app.stop() + setTimeout(() => { + this.app.start().then(() => { this.assistDemandedRestart = false }) + .then(() => { + this.remoteControl?.reconnect(ids) + }) + .catch(e => app.debug.error(e)) + // TODO: check if it's needed; basically allowing some time for the app to finish everything before starting again + }, 400) + } }) socket.on('AGENT_DISCONNECTED', (id) => { @@ -488,8 +491,6 @@ export default class Assist { return } - // UI - console.log(callUI) if (!callUI) { callUI = new CallWindow(console.log, this.options.callUITemplate) callUI.setVideoToggleCallback(updateVideoFeed)