gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated (848f4473 -> cd9a34cb)


From: gnunet
Subject: [taler-wallet-core] branch master updated (848f4473 -> cd9a34cb)
Date: Mon, 04 May 2020 14:11:31 +0200

This is an automated email from the git hooks/post-receive script.

dold pushed a change to branch master
in repository wallet-core.

    from 848f4473 handle changing permissions better
     new 42b6c58d settings tab
     new cd9a34cb make wallet notifications work again

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/webex/pages/popup.tsx   | 13 +++++++++-
 src/webex/pages/welcome.tsx | 62 +++++++++++++++++++++++++--------------------
 src/webex/wxBackend.ts      | 23 ++++++++++++++++-
 3 files changed, 68 insertions(+), 30 deletions(-)

diff --git a/src/webex/pages/popup.tsx b/src/webex/pages/popup.tsx
index f6d95e2f..a6c4651d 100644
--- a/src/webex/pages/popup.tsx
+++ b/src/webex/pages/popup.tsx
@@ -40,6 +40,7 @@ import { HistoryEvent } from "../../types/history";
 import moment from "moment";
 import { Timestamp } from "../../util/time";
 import { classifyTalerUri, TalerUriType } from "../../util/taleruri";
+import { PermissionsCheckbox } from "./welcome";
 
 // FIXME: move to newer react functions
 /* eslint-disable react/no-deprecated */
@@ -153,6 +154,7 @@ class WalletNavBar extends React.Component<any, any> {
       <div className="nav" id="header">
         <Tab target="/balance">{i18n.str`Balance`}</Tab>
         <Tab target="/history">{i18n.str`History`}</Tab>
+        <Tab target="/settings">{i18n.str`Settings`}</Tab>
         <Tab target="/debug">{i18n.str`Debug`}</Tab>
       </div>
     );
@@ -624,6 +626,15 @@ const HistoryComponent = (props: any): JSX.Element => {
   return formatHistoryItem(record);
 };
 
+class WalletSettings extends React.Component<any, any> {
+  render(): JSX.Element {
+    return <div>
+    <h2>Permissions</h2>
+    <PermissionsCheckbox />
+  </div>;
+  }
+}
+
 class WalletHistory extends React.Component<any, any> {
   private myHistory: any[];
   private gotError = false;
@@ -876,6 +887,7 @@ function WalletPopup(): JSX.Element {
         <Router>
           <WalletBalanceView route="/balance" default />
           <WalletHistory route="/history" />
+          <WalletSettings route="/settings" />
           <WalletDebug route="/debug" />
         </Router>
       </div>
@@ -884,6 +896,5 @@ function WalletPopup(): JSX.Element {
 }
 
 export function createPopup(): JSX.Element {
-  //chrome.runtime.connect({ name: "popup" });
   return <WalletPopup />;
 }
diff --git a/src/webex/pages/welcome.tsx b/src/webex/pages/welcome.tsx
index 5092d2dd..6e445e43 100644
--- a/src/webex/pages/welcome.tsx
+++ b/src/webex/pages/welcome.tsx
@@ -96,7 +96,7 @@ function Diagnostics(): JSX.Element | null {
   return <p>Running diagnostics ...</p>;
 }
 
-function Welcome(): JSX.Element {
+export function PermissionsCheckbox(): JSX.Element {
   const [extendedPermissions, setExtendedPermissions] = useState(false);
   async function handleExtendedPerm(newVal: boolean): Promise<void> {
     const res = await wxApi.setExtendedPermissions(newVal);
@@ -104,42 +104,48 @@ function Welcome(): JSX.Element {
   }
   useEffect(() => {
     async function getExtendedPermValue(): Promise<void> {
-      const res = await wxApi.getExtendedPermissions()
+      const res = await wxApi.getExtendedPermissions();
       setExtendedPermissions(res.newValue);
     }
     getExtendedPermValue();
   });
+  return (
+    <div>
+      <input
+        checked={extendedPermissions}
+        onChange={(x) => handleExtendedPerm(x.target.checked)}
+        type="checkbox"
+        id="checkbox-perm"
+        style={{ width: "1.5em", height: "1.5em", verticalAlign: "middle" }}
+      />
+      <label
+        htmlFor="checkbox-perm"
+        style={{ marginLeft: "0.5em", fontWeight: "bold" }}
+      >
+        Automatically open wallet based on page content
+      </label>
+      <span
+        style={{
+          color: "#383838",
+          fontSize: "smaller",
+          display: "block",
+          marginLeft: "2em",
+        }}
+      >
+        (Enabling this option below will make using the wallet faster, but
+        requires more permissions from your browser.)
+      </span>
+    </div>
+  );
+}
+
+function Welcome(): JSX.Element {
   return (
     <>
       <p>Thank you for installing the wallet.</p>
       <Diagnostics />
       <h2>Permissions</h2>
-      <div>
-        <input
-          checked={extendedPermissions}
-          onChange={(x) => handleExtendedPerm(x.target.checked)}
-          type="checkbox"
-          id="checkbox-perm"
-          style={{ width: "1.5em", height: "1.5em", verticalAlign: "middle" }}
-        />
-        <label
-          htmlFor="checkbox-perm"
-          style={{ marginLeft: "0.5em", fontWeight: "bold" }}
-        >
-          Automatically open wallet based on page content
-        </label>
-        <span
-          style={{
-            color: "#383838",
-            fontSize: "smaller",
-            display: "block",
-            marginLeft: "2em",
-          }}
-        >
-          (Enabling this option below will make using the wallet faster, but
-          requires more permissions from your browser.)
-        </span>
-      </div>
+      <PermissionsCheckbox />
       <h2>Next Steps</h2>
       <a href="https://demo.taler.net/"; style={{ display: "block" }}>
         Try the demo ยป
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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]