diff options
author | Sebastian <sebasjm@gmail.com> | 2023-04-18 10:47:53 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-04-18 10:47:53 -0300 |
commit | b34f3568e8c9dde73f11583a6b46ef1509990397 (patch) | |
tree | 2898223d8e67023dbfd2d338eb145bd06b737a71 /packages/taler-wallet-webextension/src/platform/dev.ts | |
parent | b1a0d034fc1be0824e1eac46661604558264beee (diff) | |
download | wallet-core-b34f3568e8c9dde73f11583a6b46ef1509990397.tar.xz |
check if the script should be injected
remove header listener
Diffstat (limited to 'packages/taler-wallet-webextension/src/platform/dev.ts')
-rw-r--r-- | packages/taler-wallet-webextension/src/platform/dev.ts | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/packages/taler-wallet-webextension/src/platform/dev.ts b/packages/taler-wallet-webextension/src/platform/dev.ts index d57072c80..1a4183bec 100644 --- a/packages/taler-wallet-webextension/src/platform/dev.ts +++ b/packages/taler-wallet-webextension/src/platform/dev.ts @@ -23,18 +23,17 @@ import { MessageFromBackend, MessageFromFrontend, MessageResponse, + defaultSettings, } from "./api.js"; const frames = ["popup", "wallet"]; const api: BackgroundPlatformAPI & ForegroundPlatformAPI = { isFirefox: () => false, + getSettingsFromStorage: () => Promise.resolve(defaultSettings), keepAlive: (cb: VoidFunction) => cb(), findTalerUriInActiveTab: async () => undefined, findTalerUriInClipboard: async () => undefined, - containsTalerHeaderListener: () => { - return true; - }, getPermissionsApi: () => ({ addPermissionsListener: () => undefined, containsHostPermissions: async () => true, @@ -47,21 +46,23 @@ const api: BackgroundPlatformAPI & ForegroundPlatformAPI = { getWalletWebExVersion: () => ({ version: "none", }), - notifyWhenAppIsReady: (fn: () => void) => { + notifyWhenAppIsReady: () => { let total = frames.length; - function waitAndNotify(): void { - total--; - if (total < 1) { - fn(); - } - } - frames.forEach((f) => { - const theFrame = window.frames[f as any]; - if (theFrame.location.href === "about:blank") { - waitAndNotify(); - } else { - theFrame.addEventListener("load", waitAndNotify); + return new Promise((fn) => { + function waitAndNotify(): void { + total--; + if (total < 1) { + fn(); + } } + frames.forEach((f) => { + const theFrame = window.frames[f as any]; + if (theFrame.location.href === "about:blank") { + waitAndNotify(); + } else { + theFrame.addEventListener("load", waitAndNotify); + } + }); }); }, @@ -80,9 +81,8 @@ const api: BackgroundPlatformAPI & ForegroundPlatformAPI = { }, registerAllIncomingConnections: () => undefined, - registerOnInstalled: (fn: () => void) => undefined, + registerOnInstalled: () => Promise.resolve(), registerReloadOnNewVersion: () => undefined, - registerTalerHeaderListener: () => undefined, useServiceWorkerAsBackgroundProcess: () => false, |