diff options
Diffstat (limited to 'packages/taler-wallet-webextension/src/walletEntryPoint.tsx')
-rw-r--r-- | packages/taler-wallet-webextension/src/walletEntryPoint.tsx | 95 |
1 files changed, 19 insertions, 76 deletions
diff --git a/packages/taler-wallet-webextension/src/walletEntryPoint.tsx b/packages/taler-wallet-webextension/src/walletEntryPoint.tsx index 023ee94c5..1bd42796b 100644 --- a/packages/taler-wallet-webextension/src/walletEntryPoint.tsx +++ b/packages/taler-wallet-webextension/src/walletEntryPoint.tsx @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2020 Taler Systems S.A. + (C) 2022 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -17,33 +17,26 @@ /** * Main entry point for extension pages. * - * @author Florian Dold <dold@taler.net> + * @author sebasjm */ import { setupI18n } from "@gnu-taler/taler-util"; -import { createHashHistory } from 'history'; -import { Fragment, h, render } from "preact"; -import Router, { route, Route } from "preact-router"; -import { useEffect } from "preact/hooks"; -import { LogoHeader } from "./components/LogoHeader"; -import { DevContextProvider } from "./context/devContext"; -import { PayPage } from "./cta/Pay"; -import { RefundPage } from "./cta/Refund"; -import { TipPage } from './cta/Tip'; -import { WithdrawPage } from "./cta/Withdraw"; -import { strings } from "./i18n/strings"; -import { - Pages, WalletNavBar -} from "./NavigationBar"; -import { BalancePage } from "./wallet/BalancePage"; -import { HistoryPage } from "./wallet/History"; -import { SettingsPage } from "./wallet/Settings"; -import { TransactionPage } from './wallet/Transaction'; -import { WelcomePage } from "./wallet/Welcome"; -import { BackupPage } from './wallet/BackupPage'; -import { DeveloperPage } from "./popup/Debug.js"; -import { ManualWithdrawPage } from "./wallet/ManualWithdrawPage.js"; - +import { h, render } from "preact"; +import { strings } from "./i18n/strings.js"; +import { setupPlatform } from "./platform/foreground.js"; +import chromeAPI from "./platform/chrome.js"; +import firefoxAPI from "./platform/firefox.js"; +import { Application } from "./wallet/Application.js"; + +const isFirefox = typeof (window as any)["InstallTrigger"] !== "undefined"; + +//FIXME: create different entry point for any platform instead of +//switching in runtime +if (isFirefox) { + setupPlatform(firefoxAPI); +} else { + setupPlatform(chromeAPI); +} function main(): void { try { @@ -60,60 +53,10 @@ function main(): void { } } -setupI18n("en-US", strings); +setupI18n("en", strings); if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", main); } else { main(); } - -function withLogoAndNavBar(Component: any) { - return (props: any) => <Fragment> - <LogoHeader /> - <WalletNavBar /> - <Component {...props} /> - </Fragment> -} - -function Application() { - return <div> - <DevContextProvider> - <Router history={createHashHistory()} > - - <Route path={Pages.welcome} component={withLogoAndNavBar(WelcomePage)} /> - - <Route path={Pages.history} component={withLogoAndNavBar(HistoryPage)} /> - <Route path={Pages.transaction} component={withLogoAndNavBar(TransactionPage)} /> - <Route path={Pages.balance} component={withLogoAndNavBar(BalancePage)} - goToWalletManualWithdraw={() => route(Pages.manual_withdraw)} - /> - <Route path={Pages.settings} component={withLogoAndNavBar(SettingsPage)} /> - <Route path={Pages.backup} component={withLogoAndNavBar(BackupPage)} /> - - <Route path={Pages.manual_withdraw} component={withLogoAndNavBar(ManualWithdrawPage)} /> - - <Route path={Pages.reset_required} component={() => <div>no yet implemented</div>} /> - <Route path={Pages.payback} component={() => <div>no yet implemented</div>} /> - <Route path={Pages.return_coins} component={() => <div>no yet implemented</div>} /> - - <Route path={Pages.dev} component={withLogoAndNavBar(DeveloperPage)} /> - - {/** call to action */} - <Route path={Pages.pay} component={PayPage} /> - <Route path={Pages.refund} component={RefundPage} /> - <Route path={Pages.tips} component={TipPage} /> - <Route path={Pages.withdraw} component={WithdrawPage} /> - - <Route default component={Redirect} to={Pages.history} /> - </Router> - </DevContextProvider> - </div> -} - -function Redirect({ to }: { to: string }): null { - useEffect(() => { - route(to, true) - }) - return null -} |