From 97a4bfbd93bc233bee36966736f006e723bae8b5 Mon Sep 17 00:00:00 2001 From: Guru Date: Mon, 2 Dec 2024 12:55:00 +0530 Subject: [PATCH 1/3] fix: broadcast channel --- src/global.ts | 4 ++++ src/main.ts | 3 +++ src/modules/controllers.ts | 21 ++++++++++++--------- src/pages/Confirm.vue | 6 +++--- src/pages/ConfirmMessage.vue | 6 +++--- src/pages/End.vue | 4 ++-- src/pages/ProviderChange.vue | 6 +++--- 7 files changed, 30 insertions(+), 20 deletions(-) create mode 100644 src/global.ts diff --git a/src/global.ts b/src/global.ts new file mode 100644 index 00000000..098966fd --- /dev/null +++ b/src/global.ts @@ -0,0 +1,4 @@ +import { broadcastChannelOptions } from "@toruslabs/base-controllers"; + +// change type +(broadcastChannelOptions as any).type = null; diff --git a/src/main.ts b/src/main.ts index eedfdfde..35a69d2c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,3 +1,6 @@ +// eslint-disable-next-line +import "@/global"; + import "@/main.css"; import { createGtm } from "@gtm-support/vue-gtm"; diff --git a/src/modules/controllers.ts b/src/modules/controllers.ts index 9ffdeec0..5f7ab106 100644 --- a/src/modules/controllers.ts +++ b/src/modules/controllers.ts @@ -9,6 +9,7 @@ import { BillboardEvent, BROADCAST_CHANNELS, BROADCAST_CHANNELS_MSGS, + broadcastChannelOptions, Contact, ContactPayload, DEFAULT_PREFERENCES, @@ -391,9 +392,10 @@ class ControllerModule extends VuexModule { public async changeTheme(theme: "light" | "dark") { const instanceId = new URLSearchParams(window.location.search).get("instanceId"); if (instanceId) { - const themeChannel = new BroadcastChannel>(`${BROADCAST_CHANNELS.THEME_CHANGE}_${instanceId}`, { - webWorkerSupport: false, - }); + const themeChannel = new BroadcastChannel>( + `${BROADCAST_CHANNELS.THEME_CHANGE}_${instanceId}`, + broadcastChannelOptions + ); themeChannel.postMessage({ data: { type: BROADCAST_CHANNELS_MSGS.SET_THEME, @@ -558,9 +560,10 @@ class ControllerModule extends VuexModule { torus.setOrigin(origin); const instanceId = new URLSearchParams(window.location.search).get("instanceId"); if (instanceId) { - const logoutChannel = new BroadcastChannel>(`${BROADCAST_CHANNELS.WALLET_LOGOUT_CHANNEL}_${instanceId}`, { - webWorkerSupport: false, - }); + const logoutChannel = new BroadcastChannel>( + `${BROADCAST_CHANNELS.WALLET_LOGOUT_CHANNEL}_${instanceId}`, + broadcastChannelOptions + ); logoutChannel.postMessage({ data: { type: BROADCAST_CHANNELS_MSGS.LOGOUT, @@ -586,7 +589,7 @@ class ControllerModule extends VuexModule { if (instanceId) { const networkChangeChannel = new BroadcastChannel>( `${BROADCAST_CHANNELS.WALLET_NETWORK_CHANGE_CHANNEL}_${instanceId}`, - { webWorkerSupport: false } + broadcastChannelOptions ); networkChangeChannel.postMessage({ data: { @@ -607,7 +610,7 @@ class ControllerModule extends VuexModule { if (instanceId) { const accountImportChannel = new BroadcastChannel>( `${BROADCAST_CHANNELS.WALLET_ACCOUNT_IMPORT_CHANNEL}_${instanceId}`, - { webWorkerSupport: false } + broadcastChannelOptions ); accountImportChannel.postMessage({ data: { @@ -637,7 +640,7 @@ class ControllerModule extends VuexModule { if (instanceId) { const selectedAddressChannel = new BroadcastChannel>( `${BROADCAST_CHANNELS.WALLET_SELECTED_ADDRESS_CHANNEL}_${instanceId}`, - { webWorkerSupport: false } + broadcastChannelOptions ); selectedAddressChannel.postMessage({ data: { diff --git a/src/pages/Confirm.vue b/src/pages/Confirm.vue index 913ced22..b4b47c29 100644 --- a/src/pages/Confirm.vue +++ b/src/pages/Confirm.vue @@ -1,6 +1,6 @@