diff --git a/src/components/OnboardingDialog.vue b/src/components/OnboardingDialog.vue index 01d53d6c..5e7489ae 100644 --- a/src/components/OnboardingDialog.vue +++ b/src/components/OnboardingDialog.vue @@ -259,7 +259,7 @@ export default class OnboardingDialog extends Vue { this.visible = true; if (this.page === OnboardPage.Create) { // we'll assume that they've been through all the other pages - await databaseUtil.updateAccountSettings(this.activeDid, { + await databaseUtil.updateDidSpecificSettings(this.activeDid, { finishedOnboarding: true, }); if (USE_DEXIE_DB) { @@ -273,7 +273,7 @@ export default class OnboardingDialog extends Vue { async onClickClose(done?: boolean, goHome?: boolean) { this.visible = false; if (done) { - await databaseUtil.updateAccountSettings(this.activeDid, { + await databaseUtil.updateDidSpecificSettings(this.activeDid, { finishedOnboarding: true, }); if (USE_DEXIE_DB) { diff --git a/src/db/databaseUtil.ts b/src/db/databaseUtil.ts index d68926fe..f5de35c0 100644 --- a/src/db/databaseUtil.ts +++ b/src/db/databaseUtil.ts @@ -37,7 +37,20 @@ export async function updateDefaultSettings( } } -export async function updateAccountSettings( +export async function insertDidSpecificSettings( + did: string, + settings: Partial = {}, +): Promise { + const platform = PlatformServiceFactory.getInstance(); + const { sql, params } = generateInsertStatement( + { ...settings, accountDid: did }, // make sure accountDid is set to the given value + "settings", + ); + const result = await platform.dbExec(sql, params); + return result.changes === 1; +} + +export async function updateDidSpecificSettings( accountDid: string, settingsChanges: Settings, ): Promise { @@ -241,6 +254,7 @@ export function generateInsertStatement( const values = Object.values(model).filter((value) => value !== undefined); const placeholders = values.map(() => "?").join(", "); const insertSql = `INSERT INTO ${tableName} (${columns.join(", ")}) VALUES (${placeholders})`; + return { sql: insertSql, params: values, diff --git a/src/libs/util.ts b/src/libs/util.ts index cd3dfc5a..6f6133f0 100644 --- a/src/libs/util.ts +++ b/src/libs/util.ts @@ -44,6 +44,7 @@ import { logger } from "../utils/logger"; import { PlatformServiceFactory } from "@/services/PlatformServiceFactory"; import { sha256 } from "ethereum-cryptography/sha256"; import { IIdentifier } from "@veramo/core"; +import { insertDidSpecificSettings } from "../db/databaseUtil"; export interface GiverReceiverInputInfo { did?: string; @@ -697,6 +698,7 @@ export async function saveNewIdentity( ]; await platformService.dbExec(sql, params); await databaseUtil.updateDefaultSettings({ activeDid: identity.did }); + await databaseUtil.insertDidSpecificSettings(identity.did); if (USE_DEXIE_DB) { // one of the few times we use accountsDBPromise directly; try to avoid more usage @@ -710,6 +712,7 @@ export async function saveNewIdentity( publicKeyHex: identity.keys[0].publicKeyHex, }); await updateDefaultSettings({ activeDid: identity.did }); + await insertDidSpecificSettings(identity.did); } } catch (error) { logger.error("Failed to update default settings:", error); @@ -732,7 +735,7 @@ export const generateSaveAndActivateIdentity = async (): Promise => { const newId = newIdentifier(address, publicHex, privateHex, derivationPath); await saveNewIdentity(newId, mnemonic, derivationPath); - await databaseUtil.updateAccountSettings(newId.did, { isRegistered: false }); + await databaseUtil.updateDidSpecificSettings(newId.did, { isRegistered: false }); if (USE_DEXIE_DB) { await updateAccountSettings(newId.did, { isRegistered: false }); } @@ -774,7 +777,7 @@ export const registerSaveAndActivatePasskey = async ( ): Promise => { const account = await registerAndSavePasskey(keyName); await databaseUtil.updateDefaultSettings({ activeDid: account.did }); - await databaseUtil.updateAccountSettings(account.did, { + await databaseUtil.updateDidSpecificSettings(account.did, { isRegistered: false, }); if (USE_DEXIE_DB) { diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue index 874c7bbc..c3fee747 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -1814,7 +1814,7 @@ export default class AccountViewView extends Vue { if (!this.isRegistered) { // the user was not known to be registered, but now they are (because we got no error) so let's record it try { - await databaseUtil.updateAccountSettings(did, { + await databaseUtil.updateDidSpecificSettings(did, { isRegistered: true, }); if (USE_DEXIE_DB) { @@ -2018,7 +2018,7 @@ export default class AccountViewView extends Vue { if ((error as any).response.status === 404) { logger.error("The image was already deleted:", error); - await databaseUtil.updateAccountSettings(this.activeDid, { + await databaseUtil.updateDidSpecificSettings(this.activeDid, { profileImageUrl: undefined, }); if (USE_DEXIE_DB) { diff --git a/src/views/ContactsView.vue b/src/views/ContactsView.vue index de94a41b..d45cf722 100644 --- a/src/views/ContactsView.vue +++ b/src/views/ContactsView.vue @@ -112,9 +112,9 @@ Copy @@ -142,16 +142,13 @@ class="text-md bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-3 py-1.5 rounded-md" @click="toggleShowContactAmounts()" > - {{ - showGiveNumbers ? "Hide Actions" : "See Actions" - }} + {{ showGiveNumbers ? "Hide Actions" : "See Actions" }}
- Only the most recent hours are included.
To see more, - click + Only the most recent hours are included.
To see more, click @@ -223,9 +220,7 @@ /> - {{ - contact.did - }} + {{ contact.did }}
{{ contact.notes }} @@ -237,7 +232,7 @@ v-if="showGiveNumbers && contact.did != activeDid" class="flex gap-1.5 items-end" > -
+
From/To