From 6e060da237af35796b1b34dce108f05eef44ceb3 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Fri, 14 Apr 2023 14:16:08 -0300
Subject: some changes

using transaction context from web utils
alertContext.safely api change (easier to integrate)
using lang and localstorage from web utils
removing auto permission, from UI
adding settings
---
 .../src/wallet/Settings.tsx                        | 65 ++++++++++------------
 1 file changed, 29 insertions(+), 36 deletions(-)

(limited to 'packages/taler-wallet-webextension/src/wallet/Settings.tsx')

diff --git a/packages/taler-wallet-webextension/src/wallet/Settings.tsx b/packages/taler-wallet-webextension/src/wallet/Settings.tsx
index 3109e8947..eea1ffb49 100644
--- a/packages/taler-wallet-webextension/src/wallet/Settings.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/Settings.tsx
@@ -36,9 +36,9 @@ import {
 import { useAlertContext } from "../context/alert.js";
 import { useBackendContext } from "../context/backend.js";
 import { useDevContext } from "../context/devContext.js";
-import { useTranslationContext } from "../context/translation.js";
+import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
 import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js";
-import { useAutoOpenPermissions } from "../hooks/useAutoOpenPermissions.js";
+import { useSettings } from "../hooks/useSettings.js";
 import { useBackupDeviceName } from "../hooks/useBackupDeviceName.js";
 import { useClipboardPermissions } from "../hooks/useClipboardPermissions.js";
 import { ToggleHandler } from "../mui/handlers.js";
@@ -48,9 +48,10 @@ import { platform } from "../platform/foreground.js";
 const GIT_HASH = typeof __GIT_HASH__ !== "undefined" ? __GIT_HASH__ : undefined;
 
 export function SettingsPage(): VNode {
-  const autoOpenToggle = useAutoOpenPermissions();
+  const [settings, updateSettings] = useSettings();
   const clipboardToggle = useClipboardPermissions();
   const { devMode, toggle } = useDevContext();
+  const { safely } = useAlertContext();
   const { name, update } = useBackupDeviceName();
   const { pushAlertOnError } = useAlertContext();
   const webex = platform.getWalletWebExVersion();
@@ -71,7 +72,15 @@ export function SettingsPage(): VNode {
       knownExchanges={exchanges}
       deviceName={name}
       setDeviceName={update}
-      autoOpenToggle={autoOpenToggle}
+      autoOpenToggle={{
+        value: settings.injectTalerSupport,
+        button: {
+          onClick: safely("update support injection", async () => {
+            console.log("click", settings.injectTalerSupport);
+            updateSettings("injectTalerSupport", !settings.injectTalerSupport);
+          }),
+        },
+      }}
       clipboardToggle={clipboardToggle}
       devModeToggle={{
         value: devMode,
@@ -115,21 +124,6 @@ export function SettingsView({
   return (
     <Fragment>
       <section>
-        {/* <Checkbox
-          label={
-            i18n.str`Automatically check clipboard for Taler URI`
-          }
-          name="clipboard"
-          description={
-            <i18n.Translate>
-              Enabling this option below will make using the wallet faster, but
-              requires more permissions from your browser.
-            </i18n.Translate>
-          }
-          enabled={clipboardToggle.value!}
-          onToggle={clipboardToggle.button.onClick!}
-        /> */}
-
         <SubTitle>
           <i18n.Translate>Trust</i18n.Translate>
         </SubTitle>
@@ -273,23 +267,22 @@ export function SettingsView({
           enabled={devModeToggle.value!}
           onToggle={devModeToggle.button.onClick!}
         />
-        <JustInDevMode>
-          <SubTitle>
-            <i18n.Translate>Navigator</i18n.Translate>
-          </SubTitle>
-          <Checkbox
-            label={i18n.str`Automatically open wallet based on page content`}
-            name="autoOpen"
-            description={
-              <i18n.Translate>
-                Enabling this option below will make using the wallet faster,
-                but requires more permissions from your browser.
-              </i18n.Translate>
-            }
-            enabled={autoOpenToggle.value!}
-            onToggle={autoOpenToggle.button.onClick!}
-          />
-        </JustInDevMode>
+        <SubTitle>
+          <i18n.Translate>Navigator</i18n.Translate>
+        </SubTitle>
+        <Checkbox
+          label={i18n.str`Automatically inject Taler API in all pages`}
+          name="inject"
+          description={
+            <i18n.Translate>
+              Disabling this option will make some web application not able to
+              trigger the wallet when clicking links but you will be able to
+              open the wallet using the keyboard shortcut
+            </i18n.Translate>
+          }
+          enabled={autoOpenToggle.value!}
+          onToggle={autoOpenToggle.button.onClick!}
+        />
       </section>
     </Fragment>
   );
-- 
cgit v1.2.3

