forked from trent_larson/crowd-funder-for-time-pwa
Adds an initial account as long as there are no available accounts.
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
import BaseDexie from "dexie";
|
import BaseDexie from "dexie";
|
||||||
import { encrypted, Encryption } from "@pvermeer/dexie-encrypted-addon";
|
import { encrypted, Encryption } from "@pvermeer/dexie-encrypted-addon";
|
||||||
import { accountsSchema, AccountsTable } from "./tables/accounts";
|
import { accountsSchema, AccountsTable } from "./tables/accounts";
|
||||||
type DexieTables = AccountsTable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In order to make the next line be acceptable, the program needs to have its linter suppress a rule:
|
* In order to make the next line be acceptable, the program needs to have its linter suppress a rule:
|
||||||
@@ -11,9 +10,8 @@ type DexieTables = AccountsTable;
|
|||||||
*
|
*
|
||||||
* https://9to5answer.com/how-to-bypass-warning-unexpected-any-specify-a-different-type-typescript-eslint-no-explicit-any
|
* https://9to5answer.com/how-to-bypass-warning-unexpected-any-specify-a-different-type-typescript-eslint-no-explicit-any
|
||||||
*/
|
*/
|
||||||
//export type Dexie<T extends any = DexieTables> = BaseDexie & T;
|
type DexieTables = AccountsTable;
|
||||||
export type Dexie<T extends unknown = DexieTables> = BaseDexie & T;
|
export type Dexie<T extends unknown = DexieTables> = BaseDexie & T;
|
||||||
|
|
||||||
export const db = new BaseDexie("kickStarter") as Dexie;
|
export const db = new BaseDexie("kickStarter") as Dexie;
|
||||||
const schema = Object.assign({}, accountsSchema);
|
const schema = Object.assign({}, accountsSchema);
|
||||||
|
|
||||||
|
|||||||
@@ -220,22 +220,28 @@ export default class AccountViewView extends Vue {
|
|||||||
privateHex,
|
privateHex,
|
||||||
UPORT_ROOT_DERIVATION_PATH
|
UPORT_ROOT_DERIVATION_PATH
|
||||||
);
|
);
|
||||||
db.open().catch(function (err) {
|
db.open()
|
||||||
console.error("Failed to open db: " + (err.stack || err));
|
.then(function (odexie) {
|
||||||
});
|
odexie._allTables.accounts.count(function (result) {
|
||||||
db.accounts
|
if (result === 0) {
|
||||||
.add({
|
console.log("No accounts");
|
||||||
publicKey: newId.keys[0].publicKeyHex,
|
odexie._allTables.accounts
|
||||||
identity: JSON.stringify(newId),
|
.add({
|
||||||
})
|
publicKey: newId.keys[0].publicKeyHex,
|
||||||
.then(function () {
|
identity: JSON.stringify(newId),
|
||||||
db.accounts.each(function (account) {
|
})
|
||||||
console.log("Found close friend: " + account.publicKey);
|
.then(function () {
|
||||||
|
odexie._allTables.accounts.each(function (account) {
|
||||||
|
console.log("Found close friend: " + account.publicKey);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.log("Skipping initial create on empty db.");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(function (e) {
|
.catch(function (err) {
|
||||||
// Something failed. It may be already in the open() call.
|
console.error("Failed to open db: " + (err.stack || err));
|
||||||
console.error(e.stack || e);
|
|
||||||
});
|
});
|
||||||
//appStore.dispatch(appSlice.actions.addLog({log: false, msg: "... created new ID..."}))
|
//appStore.dispatch(appSlice.actions.addLog({log: false, msg: "... created new ID..."}))
|
||||||
accountStore.account = JSON.stringify(newId);
|
accountStore.account = JSON.stringify(newId);
|
||||||
|
|||||||
Reference in New Issue
Block a user