gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated (f5441a68 -> 23bb82f0)


From: gnunet
Subject: [taler-wallet-core] branch master updated (f5441a68 -> 23bb82f0)
Date: Thu, 18 Aug 2022 17:48:14 +0200

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

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

    from f5441a68 fix: for bitcoin withdrawal the exchange payto:// is not 
enough and the withdrawal payto should always have the reserve pub
     new 62713c7e prevent link nav
     new 23bb82f0 disable button when wating for response

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/mui/Button.stories.tsx                     | 27 ++++++++++++++
 .../taler-wallet-webextension/src/mui/Button.tsx   | 17 ++++++++-
 packages/taler-wallet-webextension/src/stories.tsx | 43 +++++++++++++++++++---
 3 files changed, 79 insertions(+), 8 deletions(-)

diff --git a/packages/taler-wallet-webextension/src/mui/Button.stories.tsx 
b/packages/taler-wallet-webextension/src/mui/Button.stories.tsx
index 8f6b47af..385eb102 100644
--- a/packages/taler-wallet-webextension/src/mui/Button.stories.tsx
+++ b/packages/taler-wallet-webextension/src/mui/Button.stories.tsx
@@ -39,6 +39,33 @@ const Stack = styled.div`
   background-color: white;
 `;
 
+export const WithDelay = (): VNode => (
+  <Stack>
+    <Button
+      size="small"
+      variant="contained"
+      onClick={() =>
+        new Promise((resolve) => {
+          setTimeout(resolve, 2000);
+        })
+      }
+    >
+      Returns after 2 seconds
+    </Button>
+    <Button
+      size="small"
+      variant="contained"
+      onClick={() =>
+        new Promise((_, reject) => {
+          setTimeout(reject, 2000);
+        })
+      }
+    >
+      Fails after 2 seconds
+    </Button>
+  </Stack>
+);
+
 export const BasicExample = (): VNode => (
   <Fragment>
     <Stack>
diff --git a/packages/taler-wallet-webextension/src/mui/Button.tsx 
b/packages/taler-wallet-webextension/src/mui/Button.tsx
index 2f12c172..0aaa5ee9 100644
--- a/packages/taler-wallet-webextension/src/mui/Button.tsx
+++ b/packages/taler-wallet-webextension/src/mui/Button.tsx
@@ -19,6 +19,7 @@ import { css } from "@linaria/core";
 import { theme, Colors, rippleEnabled, rippleEnabledOutlined } from "./style";
 // eslint-disable-next-line import/extensions
 import { alpha } from "./colors/manipulation";
+import { useState } from "preact/hooks";
 
 export const buttonBaseStyle = css`
   display: inline-flex;
@@ -219,7 +220,7 @@ export function Button({
   size = "medium",
   style: parentStyle,
   color = "primary",
-  onClick,
+  onClick: doClick,
 }: Props): VNode {
   const style = css`
     user-select: none;
@@ -275,9 +276,21 @@ export function Button({
       }}
     />
   );
+  const [running, setRunning] = useState(false);
+
+  async function onClick(): Promise<void> {
+    if (!doClick || disabled || running) return;
+    setRunning(true);
+    try {
+      await doClick();
+    } finally {
+      setRunning(false);
+    }
+  }
+
   return (
     <ButtonBase
-      disabled={disabled}
+      disabled={disabled || running}
       class={[
         theme.typography.button,
         theme.shape.roundBorder,
diff --git a/packages/taler-wallet-webextension/src/stories.tsx 
b/packages/taler-wallet-webextension/src/stories.tsx
index 9fe0ca4e..a032222a 100644
--- a/packages/taler-wallet-webextension/src/stories.tsx
+++ b/packages/taler-wallet-webextension/src/stories.tsx
@@ -22,6 +22,7 @@ import { setupI18n } from "@gnu-taler/taler-util";
 import { styled } from "@linaria/react";
 import {
   ComponentChild,
+  ComponentChildren,
   Fragment,
   FunctionComponent,
   h,
@@ -242,33 +243,63 @@ function ExampleList({
   );
 }
 
+/**
+ * Prevents the UI from redirecting and inform the dev
+ * where the <a /> should have redirected
+ * @returns
+ */
+function PreventLinkNavigation({
+  children,
+}: {
+  children: ComponentChildren;
+}): VNode {
+  return (
+    <div
+      onClick={(e) => {
+        let t: any = e.target;
+        do {
+          if (t.localName === "a" && t.getAttribute("href")) {
+            alert(`should navigate to: ${t.attributes.href.value}`);
+            e.stopImmediatePropagation();
+            e.stopPropagation();
+            e.preventDefault();
+            return false;
+          }
+        } while ((t = t.parentNode));
+      }}
+    >
+      {children}
+    </div>
+  );
+}
+
 function getWrapperForGroup(group: string): FunctionComponent {
   switch (group) {
     case "popup":
       return function PopupWrapper({ children }: any) {
         return (
-          <Fragment>
+          <PreventLinkNavigation>
             <PopupNavBar />
             <PopupBox>{children}</PopupBox>
-          </Fragment>
+          </PreventLinkNavigation>
         );
       };
     case "wallet":
       return function WalletWrapper({ children }: any) {
         return (
-          <Fragment>
+          <PreventLinkNavigation>
             <LogoHeader />
             <WalletNavBar />
             <WalletBox>{children}</WalletBox>
-          </Fragment>
+          </PreventLinkNavigation>
         );
       };
     case "cta":
       return function WalletWrapper({ children }: any) {
         return (
-          <Fragment>
+          <PreventLinkNavigation>
             <WalletBox>{children}</WalletBox>
-          </Fragment>
+          </PreventLinkNavigation>
         );
       };
     default:

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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