From 4a781bd0dd8828ce152f6ab2c3f1bbd6b5e826f7 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Mon, 9 Jan 2023 20:20:09 -0300
Subject: fix #7153: more error handling

if handler do not trap error then fail at compile time,
all safe handlers push alert on error
errors are typed so they render good information
---
 .../src/wallet/Settings.tsx                        | 24 ++++++++--------------
 1 file changed, 9 insertions(+), 15 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 ed1bc838a..d65f3a095 100644
--- a/packages/taler-wallet-webextension/src/wallet/Settings.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/Settings.tsx
@@ -22,7 +22,6 @@ import {
 import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
 import { Fragment, h, VNode } from "preact";
 import { Checkbox } from "../components/Checkbox.js";
-import { ErrorTalerOperation } from "../components/ErrorTalerOperation.js";
 import { JustInDevMode } from "../components/JustInDevMode.js";
 import { Part } from "../components/Part.js";
 import { SelectList } from "../components/SelectList.js";
@@ -34,6 +33,7 @@ import {
   SuccessText,
   WarningText,
 } from "../components/styled/index.js";
+import { useAlertContext } from "../context/alert.js";
 import { useBackendContext } from "../context/backend.js";
 import { useDevContext } from "../context/devContext.js";
 import { useTranslationContext } from "../context/translation.js";
@@ -50,8 +50,9 @@ const GIT_HASH = typeof __GIT_HASH__ !== "undefined" ? __GIT_HASH__ : undefined;
 export function SettingsPage(): VNode {
   const autoOpenToggle = useAutoOpenPermissions();
   const clipboardToggle = useClipboardPermissions();
-  const { devModeToggle } = useDevContext();
+  const { devMode, toggle } = useDevContext();
   const { name, update } = useBackupDeviceName();
+  const { pushAlertOnError } = useAlertContext();
   const webex = platform.getWalletWebExVersion();
   const api = useBackendContext();
 
@@ -72,7 +73,12 @@ export function SettingsPage(): VNode {
       setDeviceName={update}
       autoOpenToggle={autoOpenToggle}
       clipboardToggle={clipboardToggle}
-      devModeToggle={devModeToggle}
+      devModeToggle={{
+        value: devMode,
+        button: {
+          onClick: pushAlertOnError(toggle),
+        },
+      }}
       webexVersion={{
         version: webex.version,
         hash: GIT_HASH,
@@ -109,18 +115,6 @@ export function SettingsView({
   return (
     <Fragment>
       <section>
-        {autoOpenToggle.button.error && (
-          <ErrorTalerOperation
-            title={i18n.str`Could not toggle auto-open`}
-            error={autoOpenToggle.button.error.errorDetail}
-          />
-        )}
-        {/* {clipboardToggle.button.error && (
-          <ErrorTalerOperation
-            title={i18n.str`Could not toggle clipboard`}
-            error={clipboardToggle.button.error.errorDetail}
-          />
-        )} */}
         <SubTitle>
           <i18n.Translate>Navigator</i18n.Translate>
         </SubTitle>
-- 
cgit v1.2.3

