summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/platform
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2024-02-29 15:45:22 -0300
committerSebastian <sebasjm@gmail.com>2024-02-29 15:45:22 -0300
commit206780bb0ee763bcf50a3f4f9f78579a8adcdb3a (patch)
tree7d332c27a7c64f676d6ac7101af125a806cf6318 /packages/taler-wallet-webextension/src/platform
parent922d5b4d7aeed3f7c2f9eab1482f60d2fa50f234 (diff)
downloadwallet-core-206780bb0ee763bcf50a3f4f9f78579a8adcdb3a.tar.gz
wallet-core-206780bb0ee763bcf50a3f4f9f78579a8adcdb3a.tar.bz2
wallet-core-206780bb0ee763bcf50a3f4f9f78579a8adcdb3a.zip
observe UI, WIP
Diffstat (limited to 'packages/taler-wallet-webextension/src/platform')
-rw-r--r--packages/taler-wallet-webextension/src/platform/api.ts12
-rw-r--r--packages/taler-wallet-webextension/src/platform/chrome.ts13
-rw-r--r--packages/taler-wallet-webextension/src/platform/dev.ts1
3 files changed, 25 insertions, 1 deletions
diff --git a/packages/taler-wallet-webextension/src/platform/api.ts b/packages/taler-wallet-webextension/src/platform/api.ts
index e3afe35bd..faf0f2820 100644
--- a/packages/taler-wallet-webextension/src/platform/api.ts
+++ b/packages/taler-wallet-webextension/src/platform/api.ts
@@ -55,6 +55,7 @@ export interface CrossBrowserPermissionsApi {
export enum ExtensionNotificationType {
SettingsChange = "settings-change",
+ ClearNotifications = "clear-notifications",
}
export interface SettingsChangeNotification {
@@ -62,8 +63,11 @@ export interface SettingsChangeNotification {
currentValue: Settings;
}
+export interface ClearNotificaitonNotification {
+ type: ExtensionNotificationType.ClearNotifications;
+}
-export type ExtensionNotification = SettingsChangeNotification
+export type ExtensionNotification = SettingsChangeNotification | ClearNotificaitonNotification
export type MessageFromBackend = {
type: "wallet",
@@ -300,6 +304,12 @@ export interface ForegroundPlatformAPI {
): Promise<MessageResponse>;
/**
+ * Used by the wallet frontend to send notification about new information
+ * @param message
+ */
+ triggerWalletEvent(message: MessageFromBackend): void;
+
+ /**
* Used from the frontend to receive notifications about new information
* @param listener
* @return function to unsubscribe the listener
diff --git a/packages/taler-wallet-webextension/src/platform/chrome.ts b/packages/taler-wallet-webextension/src/platform/chrome.ts
index d88dae460..fc2d1db09 100644
--- a/packages/taler-wallet-webextension/src/platform/chrome.ts
+++ b/packages/taler-wallet-webextension/src/platform/chrome.ts
@@ -45,6 +45,7 @@ const api: BackgroundPlatformAPI & ForegroundPlatformAPI = {
findTalerUriInClipboard,
getPermissionsApi,
getWalletWebExVersion,
+ triggerWalletEvent,
listenToWalletBackground,
notifyWhenAppIsReady,
openWalletPage,
@@ -324,6 +325,18 @@ function listenToWalletBackground(listener: (m: any) => void): () => void {
const allPorts: chrome.runtime.Port[] = [];
+
+function triggerWalletEvent(message: MessageFromBackend): void {
+ for (const notif of allPorts) {
+ // const message: MessageFromBackend = { type: msg.type };
+ try {
+ notif.postMessage(message);
+ } catch (e) {
+ logger.error("error posting a message", e);
+ }
+ }
+}
+
function sendMessageToAllChannels(message: MessageFromBackend): void {
for (const notif of allPorts) {
// const message: MessageFromBackend = { type: msg.type };
diff --git a/packages/taler-wallet-webextension/src/platform/dev.ts b/packages/taler-wallet-webextension/src/platform/dev.ts
index 2993c88bc..7cbbe5b25 100644
--- a/packages/taler-wallet-webextension/src/platform/dev.ts
+++ b/packages/taler-wallet-webextension/src/platform/dev.ts
@@ -36,6 +36,7 @@ const api: BackgroundPlatformAPI & ForegroundPlatformAPI = {
findTalerUriInClipboard: async () => undefined,
listenNetworkConnectionState,
openNewURLFromPopup: () => undefined,
+ triggerWalletEvent: () => undefined,
getPermissionsApi: () => ({
containsClipboardPermissions: async () => true,
removeClipboardPermissions: async () => false,