From e8e0f315f8f8f730c982054c16d739a61ef2e14d Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Mon, 22 Sep 2025 20:17:56 -0600 Subject: [PATCH 1/5] feat: copy important old settings from master record to others --- src/db-sql/migration.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/db-sql/migration.ts b/src/db-sql/migration.ts index 5ee221f5..14dc36d4 100644 --- a/src/db-sql/migration.ts +++ b/src/db-sql/migration.ts @@ -68,6 +68,16 @@ const MIG_004_SQL = ` WHERE id = 1 AND EXISTS (SELECT 1 FROM settings WHERE id = 1 AND activeDid IS NOT NULL AND activeDid != ''); + -- Copy important settings that were set in the MASTER_SETTINGS_KEY to all the other identities. + -- (We're not doing them all because some were already identity-specific and others aren't as critical.) + UPDATE settings + SET firstName = (SELECT firstName FROM settings WHERE id = 1), + lastViewedClaimId = (SELECT lastViewedClaimId FROM settings WHERE id = 1), + profileImageUrl = (SELECT profileImageUrl FROM settings WHERE id = 1), + showShortcutBvc = (SELECT showShortcutBvc FROM settings WHERE id = 1), + warnIfProdServer = (SELECT warnIfProdServer FROM settings WHERE id = 1), + warnIfTestServer = (SELECT warnIfTestServer FROM settings WHERE id = 1); + -- CLEANUP: Remove orphaned settings records and clear legacy activeDid values -- This completes the migration from settings-based to table-based active identity -- Use guarded operations to prevent accidental data loss From c0f407eb7266b7e4d4228ccf14d7e8fca4d5653c Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Mon, 22 Sep 2025 20:18:38 -0600 Subject: [PATCH 2/5] chore: remove saveMySettings that depended on an implicit variable --- src/components/TopMessage.vue | 2 +- src/services/migrationService.ts | 2 +- src/utils/PlatformServiceMixin.ts | 9 ++++++++- src/views/HomeView.vue | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/components/TopMessage.vue b/src/components/TopMessage.vue index 080aa6dd..9975101e 100644 --- a/src/components/TopMessage.vue +++ b/src/components/TopMessage.vue @@ -28,7 +28,7 @@ import { logger } from "../utils/logger"; export default class TopMessage extends Vue { // Enhanced PlatformServiceMixin v4.0 provides: // - Cached database operations: this.$contacts(), this.$settings(), this.$accountSettings() - // - Settings shortcuts: this.$saveSettings(), this.$saveMySettings() + // - Settings shortcuts: this.$saveSettings() // - Cache management: this.$refreshSettings(), this.$clearAllCaches() // - Ultra-concise database methods: this.$db(), this.$exec(), this.$query() // - All methods use smart caching with TTL for massive performance gains diff --git a/src/services/migrationService.ts b/src/services/migrationService.ts index 87405cce..e1369f5d 100644 --- a/src/services/migrationService.ts +++ b/src/services/migrationService.ts @@ -799,7 +799,7 @@ export async function runMigrations( } // Only show completion message in development - logger.debug( + logger.log( `🎉 [Migration] Migration process complete! Summary: ${appliedCount} applied, ${skippedCount} skipped`, ); } catch (error) { diff --git a/src/utils/PlatformServiceMixin.ts b/src/utils/PlatformServiceMixin.ts index 7fe727be..2e8b8a77 100644 --- a/src/utils/PlatformServiceMixin.ts +++ b/src/utils/PlatformServiceMixin.ts @@ -1212,6 +1212,11 @@ export const PlatformServiceMixin = { * @param changes Settings changes to save * @returns Promise Success status */ + /** + * Since this is unused, and since it relies on this.activeDid which isn't guaranteed to exist, + * let's take this out for the sake of safety. + * Totally remove after start of 2026 (since it would be obvious by then that it's not used). + * async $saveMySettings(changes: Partial): Promise { // eslint-disable-next-line @typescript-eslint/no-explicit-any const currentDid = (this as any).activeDid; @@ -1221,6 +1226,7 @@ export const PlatformServiceMixin = { } return await this.$saveUserSettings(currentDid, changes); }, + **/ // ================================================= // CACHE MANAGEMENT METHODS @@ -2040,7 +2046,8 @@ declare module "@vue/runtime-core" { did: string, changes: Partial, ): Promise; - $saveMySettings(changes: Partial): Promise; + // @deprecated; see implementation note above + // $saveMySettings(changes: Partial): Promise; // Cache management methods $refreshSettings(): Promise; diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 9374d079..e8d2035a 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -645,7 +645,9 @@ export default class HomeView extends Vue { if (resp.status === 200) { // Ultra-concise settings update with automatic cache invalidation! - await this.$saveMySettings({ isRegistered: true }); + await this.$saveUserSettings(this.activeDid, { + isRegistered: true, + }); this.isRegistered = true; } } catch (error) { From 46d7fee95ea0172a8dcc20b9af214473cbf05ee1 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Wed, 24 Sep 2025 09:10:21 -0600 Subject: [PATCH 3/5] fix: remove settings, too, when deleting an identity --- src/db-sql/migration.ts | 2 +- src/views/IdentitySwitcherView.vue | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/db-sql/migration.ts b/src/db-sql/migration.ts index 14dc36d4..81b3d913 100644 --- a/src/db-sql/migration.ts +++ b/src/db-sql/migration.ts @@ -79,8 +79,8 @@ const MIG_004_SQL = ` warnIfTestServer = (SELECT warnIfTestServer FROM settings WHERE id = 1); -- CLEANUP: Remove orphaned settings records and clear legacy activeDid values + -- which usually simply clears out the MASTER_SETTINGS_KEY record. -- This completes the migration from settings-based to table-based active identity - -- Use guarded operations to prevent accidental data loss DELETE FROM settings WHERE accountDid IS NULL; UPDATE settings SET activeDid = NULL; `; diff --git a/src/views/IdentitySwitcherView.vue b/src/views/IdentitySwitcherView.vue index 0e5516e6..8a369ac6 100644 --- a/src/views/IdentitySwitcherView.vue +++ b/src/views/IdentitySwitcherView.vue @@ -306,6 +306,7 @@ export default class IdentitySwitcherView extends Vue { } await this.$exec("DELETE FROM accounts WHERE id = ?", [id]); + await this.$exec("DELETE FROM settings WHERE accountDid = ?", [accountDid]); }); // Update UI From f5bea249217f3538640e991cfe74715347c6acef Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Wed, 24 Sep 2025 18:51:48 -0600 Subject: [PATCH 4/5] fix: linting --- src/views/IdentitySwitcherView.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/views/IdentitySwitcherView.vue b/src/views/IdentitySwitcherView.vue index 8a369ac6..9d80689d 100644 --- a/src/views/IdentitySwitcherView.vue +++ b/src/views/IdentitySwitcherView.vue @@ -306,7 +306,9 @@ export default class IdentitySwitcherView extends Vue { } await this.$exec("DELETE FROM accounts WHERE id = ?", [id]); - await this.$exec("DELETE FROM settings WHERE accountDid = ?", [accountDid]); + await this.$exec("DELETE FROM settings WHERE accountDid = ?", [ + accountDid, + ]); }); // Update UI From d6524cbd4390f0fe9bb51aae12853bfd53e788d5 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Wed, 24 Sep 2025 19:29:28 -0600 Subject: [PATCH 5/5] fix: don't lose the name when running the migration --- src/db-sql/migration.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/db-sql/migration.ts b/src/db-sql/migration.ts index 81b3d913..f686d155 100644 --- a/src/db-sql/migration.ts +++ b/src/db-sql/migration.ts @@ -68,18 +68,18 @@ const MIG_004_SQL = ` WHERE id = 1 AND EXISTS (SELECT 1 FROM settings WHERE id = 1 AND activeDid IS NOT NULL AND activeDid != ''); - -- Copy important settings that were set in the MASTER_SETTINGS_KEY to all the other identities. + -- Copy important settings that were set in the MASTER_SETTINGS_KEY to the main identity. -- (We're not doing them all because some were already identity-specific and others aren't as critical.) UPDATE settings - SET firstName = (SELECT firstName FROM settings WHERE id = 1), - lastViewedClaimId = (SELECT lastViewedClaimId FROM settings WHERE id = 1), + SET lastViewedClaimId = (SELECT lastViewedClaimId FROM settings WHERE id = 1), profileImageUrl = (SELECT profileImageUrl FROM settings WHERE id = 1), showShortcutBvc = (SELECT showShortcutBvc FROM settings WHERE id = 1), warnIfProdServer = (SELECT warnIfProdServer FROM settings WHERE id = 1), - warnIfTestServer = (SELECT warnIfTestServer FROM settings WHERE id = 1); + warnIfTestServer = (SELECT warnIfTestServer FROM settings WHERE id = 1) + WHERE id = 2; -- CLEANUP: Remove orphaned settings records and clear legacy activeDid values - -- which usually simply clears out the MASTER_SETTINGS_KEY record. + -- which usually simply deletes the MASTER_SETTINGS_KEY record. -- This completes the migration from settings-based to table-based active identity DELETE FROM settings WHERE accountDid IS NULL; UPDATE settings SET activeDid = NULL;