diff options
author | Sebastian <sebasjm@gmail.com> | 2022-06-03 10:19:33 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-06-03 10:19:33 -0300 |
commit | d2563c16473b2848ecf8a45474dd43983faceac0 (patch) | |
tree | 5ba5b6827aa8cfc152aedc5ca742f5bc83c49dfd | |
parent | 5d9390bb3437171353db99e7afd8cbcca432ba5c (diff) |
use preact matcher internal api callv0.9.0-dev.12
-rw-r--r-- | packages/taler-wallet-webextension/src/wallet/Application.tsx | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/packages/taler-wallet-webextension/src/wallet/Application.tsx b/packages/taler-wallet-webextension/src/wallet/Application.tsx index 84aa0dd84..b0527f72d 100644 --- a/packages/taler-wallet-webextension/src/wallet/Application.tsx +++ b/packages/taler-wallet-webextension/src/wallet/Application.tsx @@ -247,8 +247,23 @@ function Redirect({ to }: { to: string }): null { return null; } -function shouldShowPendingOperations(path: string): boolean { - // FIXME: replace includes with a match API like preact router does - // [Pages.balanceHistory, Pages.dev, Pages.settings, Pages.backup] - return ["/balance/history/", "/dev", "/settings", "/backup"].includes(path); +function matchesRoute(url: string, route: string): boolean { + type MatcherFunc = ( + url: string, + route: string, + opts: any, + ) => Record<string, string> | false; + + const internalPreactMatcher: MatcherFunc = (Router as any).exec; + const result = internalPreactMatcher(url, route, {}); + return !result ? false : true; +} + +function shouldShowPendingOperations(url: string): boolean { + return [ + Pages.balanceHistory.pattern, + Pages.dev, + Pages.settings, + Pages.backup, + ].some((p) => matchesRoute(url, p)); } |