gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated (962bfde2 -> 62911fd5)


From: gnunet
Subject: [taler-wallet-core] branch master updated (962bfde2 -> 62911fd5)
Date: Wed, 14 Sep 2022 13:20:17 +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 962bfde2 wallet-core: fix withdrawTestBalance command
     new f026a8d3 import a complete database from cli
     new 62911fd5 stories resize (wip)

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:
 packages/taler-wallet-core/src/db.ts               | 52 ++++++++++++++++++++--
 .../src/NavigationBar.tsx                          |  4 +-
 packages/taler-wallet-webextension/src/stories.tsx | 39 +++++++++++++++-
 .../src/wallet/History.tsx                         |  5 +--
 4 files changed, 90 insertions(+), 10 deletions(-)

diff --git a/packages/taler-wallet-core/src/db.ts 
b/packages/taler-wallet-core/src/db.ts
index 832bbb9a..da566ff2 100644
--- a/packages/taler-wallet-core/src/db.ts
+++ b/packages/taler-wallet-core/src/db.ts
@@ -2024,11 +2024,11 @@ export interface DatabaseDump {
   version: string;
 }
 
-export function importDb(db: IDBDatabase, dump: DatabaseDump): Promise<any> {
+async function recoverFromDump(db: IDBDatabase, dump: DatabaseDump): 
Promise<void> {
   return new Promise((resolve, reject) => {
     const tx = db.transaction(Array.from(db.objectStoreNames), "readwrite");
     tx.addEventListener("complete", () => {
-      resolve(db);
+      resolve();
     });
     for (let i = 0; i < db.objectStoreNames.length; i++) {
       const name = db.objectStoreNames[i];
@@ -2041,5 +2041,51 @@ export function importDb(db: IDBDatabase, dump: 
DatabaseDump): Promise<any> {
       });
     }
     tx.commit();
-  });
+  })
+}
+
+export async function importDb(db: IDBDatabase, object: any): Promise<void> {
+  if ("name" in object && "stores" in object && "version" in object) {
+    // looks like a database dump
+    const dump = object as DatabaseDump
+    return recoverFromDump(db, dump);
+  }
+
+  if ("databases" in object && "$types" in object) {
+    // looks like a IDBDatabase
+    const someDatabase = object.databases;
+
+    if (TALER_META_DB_NAME in someDatabase) {
+      //looks like a taler database
+      const currentMainDbValue = 
someDatabase[TALER_META_DB_NAME].objectStores.metaConfig.records[0].value.value
+
+      if (currentMainDbValue !== TALER_DB_NAME) {
+        console.log("not the current database version")
+      }
+
+      const talerDb = someDatabase[currentMainDbValue];
+
+      const objectStoreNames = Object.keys(talerDb.objectStores);
+
+      const dump: DatabaseDump = {
+        name: talerDb.schema.databaseName,
+        version: talerDb.schema.databaseVersion,
+        stores: {},
+      }
+
+      for (let i = 0; i < objectStoreNames.length; i++) {
+        const name = objectStoreNames[i];
+        const storeDump = {} as { [s: string]: any };
+        dump.stores[name] = storeDump;
+        talerDb.objectStores[name].records.map((r: any) => {
+          const pkey = r.primaryKey
+          const key = typeof pkey === "string" ? pkey : pkey.join(",")
+          storeDump[key] = r.value;
+        })
+      }
+
+      return recoverFromDump(db, dump);
+    }
+  }
+  throw Error("could not import database");
 }
diff --git a/packages/taler-wallet-webextension/src/NavigationBar.tsx 
b/packages/taler-wallet-webextension/src/NavigationBar.tsx
index 9b222cdb..f6c56af1 100644
--- a/packages/taler-wallet-webextension/src/NavigationBar.tsx
+++ b/packages/taler-wallet-webextension/src/NavigationBar.tsx
@@ -143,7 +143,7 @@ export function PopupNavBar({ path = "" }: { path?: string 
}): VNode {
       <div style={{ display: "flex", paddingTop: 4, justifyContent: "right" }}>
         <a href={Pages.qr}>
           <SvgIcon
-            title={i18n.str`QR Reader`}
+            title={i18n.str`QR Reader and Taler URI`}
             dangerouslySetInnerHTML={{ __html: qrIcon }}
             color="white"
           />
@@ -189,7 +189,7 @@ export function WalletNavBar({ path = "" }: { path?: string 
}): VNode {
         >
           <a href={Pages.qr}>
             <SvgIcon
-              title={i18n.str`QR Reader`}
+              title={i18n.str`QR Reader and Taler URI`}
               dangerouslySetInnerHTML={{ __html: qrIcon }}
               color="white"
             />
diff --git a/packages/taler-wallet-webextension/src/stories.tsx 
b/packages/taler-wallet-webextension/src/stories.tsx
index 09261d6f..02cc1539 100644
--- a/packages/taler-wallet-webextension/src/stories.tsx
+++ b/packages/taler-wallet-webextension/src/stories.tsx
@@ -62,7 +62,7 @@ const Page = styled.div`
 `;
 
 const SideBar = styled.div`
-  min-width: 200px;
+  min-width: var(--with-size);
   height: calc(100vh - 20px);
   overflow-y: visible;
   overflow-x: hidden;
@@ -106,6 +106,35 @@ const SideBar = styled.div`
   }
 `;
 
+const ResizeHandleDiv = styled.div`
+  width: 10px;
+  background: #ddd;
+  cursor: ew-resize;
+`;
+
+function ResizeHandle({ onUpdate }: { onUpdate: (x: number) => void }): VNode {
+  const [start, setStart] = useState<number | undefined>(undefined);
+  return (
+    <ResizeHandleDiv
+      onMouseDown={(e: any) => {
+        setStart(e.pageX);
+        console.log("active", e.pageX);
+        return false;
+      }}
+      onMouseMove={(e: any) => {
+        if (start !== undefined) {
+          onUpdate(e.pageX - start);
+        }
+        return false;
+      }}
+      onMouseUp={() => {
+        setStart(undefined);
+        return false;
+      }}
+    />
+  );
+}
+
 const Content = styled.div`
   width: 100%;
   padding: 20px;
@@ -380,11 +409,12 @@ function Application(): VNode {
   const ExampleContent = getContentForExample(selected);
 
   const GroupWrapper = getWrapperForGroup(selected?.group || "default");
+  const [sidebarWidth, setSidebarWidth] = useState(200);
 
   return (
     <Page>
       <LiveReload />
-      <SideBar>
+      <SideBar style={{ "--with-size": `${sidebarWidth}px` }}>
         {allExamples.map((e) => (
           <ExampleList
             key={e.title}
@@ -401,6 +431,11 @@ function Application(): VNode {
         ))}
         <hr />
       </SideBar>
+      <ResizeHandle
+        onUpdate={(x) => {
+          setSidebarWidth((s) => s + x);
+        }}
+      />
       <Content>
         <ErrorReport selected={selected}>
           <GroupWrapper>
diff --git a/packages/taler-wallet-webextension/src/wallet/History.tsx 
b/packages/taler-wallet-webextension/src/wallet/History.tsx
index 6a8362dd..53913501 100644
--- a/packages/taler-wallet-webextension/src/wallet/History.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/History.tsx
@@ -25,7 +25,6 @@ import { useEffect, useState } from "preact/hooks";
 import { Loading } from "../components/Loading.js";
 import { LoadingError } from "../components/LoadingError.js";
 import {
-  ButtonBoxPrimary,
   CenteredBoldText,
   CenteredText,
   DateSeparator,
@@ -37,6 +36,8 @@ import { useTranslationContext } from 
"../context/translation.js";
 import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js";
 import { Button } from "../mui/Button.js";
 import { NoBalanceHelp } from "../popup/NoBalanceHelp.js";
+import DownloadIcon from "../svg/download_24px.svg";
+import UploadIcon from "../svg/upload_24px.svg";
 import * as wxApi from "../wxApi.js";
 
 interface Props {
@@ -96,8 +97,6 @@ const term = 1000 * 60 * 60 * 24;
 function normalizeToDay(x: number): number {
   return Math.round(x / term) * term;
 }
-import DownloadIcon from "../svg/download_24px.svg";
-import UploadIcon from "../svg/upload_24px.svg";
 
 export function HistoryView({
   defaultCurrency,

-- 
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]