forked from jsnbuchanan/crowd-funder-for-time-pwa
fix problems with race conditions and multiple DatabaseService instances
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
updateAccountSettings,
|
||||
updateDefaultSettings,
|
||||
} from "../db/index";
|
||||
import databaseService from "../services/database";
|
||||
import { Account } from "../db/tables/accounts";
|
||||
import { Contact } from "../db/tables/contacts";
|
||||
import { DEFAULT_PASSKEY_EXPIRATION_MINUTES } from "../db/tables/settings";
|
||||
@@ -550,6 +551,20 @@ export const generateSaveAndActivateIdentity = async (): Promise<string> => {
|
||||
publicKeyHex: newId.keys[0].publicKeyHex,
|
||||
});
|
||||
|
||||
// add to the new sql db
|
||||
await databaseService.run(
|
||||
`INSERT INTO accounts (dateCreated, derivationPath, did, identity, mnemonic, publicKeyHex)
|
||||
VALUES (?, ?, ?, ?, ?, ?)`,
|
||||
[
|
||||
new Date().toISOString(),
|
||||
derivationPath,
|
||||
newId.did,
|
||||
identity,
|
||||
mnemonic,
|
||||
newId.keys[0].publicKeyHex
|
||||
]
|
||||
);
|
||||
|
||||
await updateDefaultSettings({ activeDid: newId.did });
|
||||
} catch (error) {
|
||||
console.error("Failed to update default settings:", error);
|
||||
|
||||
Reference in New Issue
Block a user