Skip to content

Commit

Permalink
Merge branch 'master' of github.com:binary-com/deriv-app into niloo/8…
Browse files Browse the repository at this point in the history
…4471/ts-migration-parent
  • Loading branch information
Niloofar Sadeghi committed Jan 8, 2023
2 parents 3a2c274 + b134c88 commit 9a49b2f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/bot-skeleton/src/scratch/dbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ class DBot {
}
}

terminateConnection = () => {
api_base.terminate();
};

/**
* Unselects any selected block before running the bot.
*/
Expand Down
8 changes: 7 additions & 1 deletion packages/bot-skeleton/src/services/api/api-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class APIBase {
init(force_update = false) {
if (getLoginId()) {
this.toggleRunButton(true);
if (force_update && this.api) this.api.disconnect();
if (force_update) this.terminate();
this.api = generateDerivApiInstance();
this.initEventListeners();
this.authorizeAndSubscribe();
Expand All @@ -24,6 +24,12 @@ class APIBase {
}
}

terminate() {
// eslint-disable-next-line no-console
console.log('connection terminated');
if (this.api) this.api.disconnect();
}

initEventListeners() {
if (window) {
window.addEventListener('online', this.reconnectIfNotConnected);
Expand Down
2 changes: 1 addition & 1 deletion packages/bot-web-ui/src/stores/app-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default class AppStore {

onUnmount() {
DBot.terminateBot();

DBot.terminateConnection();
if (Blockly.derivWorkspace) {
clearInterval(Blockly.derivWorkspace.save_workspace_interval);
Blockly.derivWorkspace.dispose();
Expand Down

0 comments on commit 9a49b2f

Please sign in to comment.