From 2e71117f59e0ae6106930e705ae6a54a9839281b Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 23 Dec 2021 15:17:36 -0300 Subject: deposit from wallet webex: wip --- .../src/popup/DeveloperPage.tsx | 68 +++++++++++++++++----- 1 file changed, 52 insertions(+), 16 deletions(-) (limited to 'packages/taler-wallet-webextension/src/popup/DeveloperPage.tsx') diff --git a/packages/taler-wallet-webextension/src/popup/DeveloperPage.tsx b/packages/taler-wallet-webextension/src/popup/DeveloperPage.tsx index b32555248..b689004cc 100644 --- a/packages/taler-wallet-webextension/src/popup/DeveloperPage.tsx +++ b/packages/taler-wallet-webextension/src/popup/DeveloperPage.tsx @@ -43,14 +43,17 @@ export function DeveloperPage(): VNode { ? [] : operationsResponse.response.pendingOperations; - return { - const db = await wxApi.exportDB() - return JSON.stringify(db) - }} - />; + return ( + { + const db = await wxApi.exportDB(); + return JSON.stringify(db); + }} + /> + ); } export interface Props { @@ -64,14 +67,21 @@ function hashObjectId(o: any): string { return JSON.stringify(o); } -export function View({ status, timedOut, operations, onDownloadDatabase }: Props): VNode { - const [downloadedDatabase, setDownloadedDatabase] = useState<{time: Date; content: string}|undefined>(undefined) +export function View({ + status, + timedOut, + operations, + onDownloadDatabase, +}: Props): VNode { + const [downloadedDatabase, setDownloadedDatabase] = useState< + { time: Date; content: string } | undefined + >(undefined); async function onExportDatabase(): Promise { - const content = await onDownloadDatabase() + const content = await onDownloadDatabase(); setDownloadedDatabase({ time: new Date(), - content - }) + content, + }); } return (
@@ -83,9 +93,27 @@ export function View({ status, timedOut, operations, onDownloadDatabase }: Props
- {downloadedDatabase &&
- Database exported at
} + {downloadedDatabase && ( +
+ Database exported at +
+ )}
{operations && operations.length > 0 && ( @@ -109,6 +137,14 @@ export function View({ status, timedOut, operations, onDownloadDatabase }: Props ); } +function toBase64(str: string): string { + return btoa( + encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p1) { + return String.fromCharCode(parseInt(p1, 16)); + }), + ); +} + export function reload(): void { try { // eslint-disable-next-line no-undef -- cgit v1.2.3