[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] 02/02: make wallet notifications work again
From: |
gnunet |
Subject: |
[taler-wallet-core] 02/02: make wallet notifications work again |
Date: |
Mon, 04 May 2020 14:11:33 +0200 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository wallet-core.
commit cd9a34cbb5ca8fb1c61aeda50517de60cc829e29
Author: Florian Dold <address@hidden>
AuthorDate: Mon May 4 17:41:22 2020 +0530
make wallet notifications work again
---
src/webex/pages/popup.tsx | 1 -
src/webex/wxBackend.ts | 23 ++++++++++++++++++++++-
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/src/webex/pages/popup.tsx b/src/webex/pages/popup.tsx
index 7da8056d..a6c4651d 100644
--- a/src/webex/pages/popup.tsx
+++ b/src/webex/pages/popup.tsx
@@ -896,6 +896,5 @@ function WalletPopup(): JSX.Element {
}
export function createPopup(): JSX.Element {
- //chrome.runtime.connect({ name: "popup" });
return <WalletPopup />;
}
diff --git a/src/webex/wxBackend.ts b/src/webex/wxBackend.ts
index 7966bbe2..54dd35ac 100644
--- a/src/webex/wxBackend.ts
+++ b/src/webex/wxBackend.ts
@@ -68,6 +68,8 @@ const extendedPermissions = {
origins: ["http://*/*", "https://*/*"],
};
+const notificationPorts: chrome.runtime.Port[] = [];
+
async function handleMessage(
sender: MessageSender,
type: MessageType,
@@ -447,6 +449,15 @@ async function reinitWallet(): Promise<void> {
http,
new BrowserCryptoWorkerFactory(),
);
+ wallet.addNotificationListener((x) => {
+ for (const x of notificationPorts) {
+ try {
+ x.postMessage({ type: "notification" });
+ } catch (e) {
+ console.error(e);
+ }
+ }
+ });
wallet.runRetryLoop().catch((e) => {
console.log("error during wallet retry loop", e);
});
@@ -620,8 +631,18 @@ export async function wxMain(): Promise<void> {
return true;
});
+ chrome.runtime.onConnect.addListener((port) => {
+ notificationPorts.push(port);
+ port.onDisconnect.addListener((discoPort) => {
+ const idx = notificationPorts.indexOf(discoPort);
+ if (idx >= 0) {
+ notificationPorts.splice(idx, 1);
+ }
+ });
+ });
+
setupHeaderListener();
-
+
chrome.permissions.onAdded.addListener((perm) => {
if (chrome.runtime.lastError) {
console.error(chrome.runtime.lastError);
--
To stop receiving notification emails like this one, please contact
address@hidden.