diff options
author | Sebastian <sebasjm@gmail.com> | 2022-10-24 11:12:28 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-10-24 11:12:28 -0300 |
commit | 1e39c57cb972c6de224c177dd28ae3a315fbe590 (patch) | |
tree | 0c2869e59837aefcd7a7231271be2f6350ee0151 /packages/taler-wallet-webextension/src/context/devContext.ts | |
parent | 7a80d33414e1bcac51b4704b30499b781fffc064 (diff) | |
download | wallet-core-1e39c57cb972c6de224c177dd28ae3a315fbe590.tar.xz |
wallet dev mode and backup into devmode
Diffstat (limited to 'packages/taler-wallet-webextension/src/context/devContext.ts')
-rw-r--r-- | packages/taler-wallet-webextension/src/context/devContext.ts | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/packages/taler-wallet-webextension/src/context/devContext.ts b/packages/taler-wallet-webextension/src/context/devContext.ts index b710716b5..c494b9403 100644 --- a/packages/taler-wallet-webextension/src/context/devContext.ts +++ b/packages/taler-wallet-webextension/src/context/devContext.ts @@ -21,16 +21,17 @@ import { createContext, h, VNode } from "preact"; import { useContext } from "preact/hooks"; -import { useLocalStorage } from "../hooks/useLocalStorage.js"; +import { useWalletDevMode } from "../hooks/useWalletDevMode.js"; +import { ToggleHandler } from "../mui/handlers.js"; interface Type { devMode: boolean; - toggleDevMode: () => Promise<void>; + devModeToggle: ToggleHandler; } const Context = createContext<Type>({ devMode: false, - toggleDevMode: async () => { - return; + devModeToggle: { + button: {}, }, }); @@ -40,28 +41,28 @@ export const DevContextProviderForTesting = ({ value, children, }: { - value: boolean; + value?: boolean; children: any; }): VNode => { return h(Context.Provider, { value: { - devMode: value, - toggleDevMode: async () => { - return; - }, + devMode: !!value, + devModeToggle: { + value, button: {} + } }, children, }); }; export const DevContextProvider = ({ children }: { children: any }): VNode => { - const [value, setter] = useLocalStorage("devMode"); - const devMode = value === "true"; - const toggleDevMode = async (): Promise<void> => - setter((v) => (!v ? "true" : undefined)); + const devModeToggle = useWalletDevMode(); + const value: Type = { devMode: !!devModeToggle.value, devModeToggle } + //support for function as children, useful for getting the value right away children = children.length === 1 && typeof children === "function" - ? children({ devMode }) + ? children(value) : children; - return h(Context.Provider, { value: { devMode, toggleDevMode }, children }); + + return h(Context.Provider, { value, children }); }; |