From 8eb4ad5c7415ae4c0d020386836de8a87a53ea32 Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Thu, 11 Sep 2025 05:37:40 +0000 Subject: [PATCH] refactor: Remove defunct $needsActiveIdentitySelection method and fix activeDid consistency ## Changes Made ### Code Cleanup - Remove unused $needsActiveIdentitySelection() method (36 lines) - Remove method signature from IPlatformServiceMixin interface - Remove method signature from Vue module declaration ### Database Consistency Fix - Change activeDid clearing from empty string ('') to NULL for consistency - Ensures proper foreign key constraint compatibility - Maintains API compatibility by still returning empty string to components ## Impact - Reduces codebase complexity by removing unused functionality - Improves database integrity with consistent NULL usage - No breaking changes to component APIs - Migration and auto-selection now handle all identity management ## Files Changed - src/utils/PlatformServiceMixin.ts: -42 lines, +1 line --- src/utils/PlatformServiceMixin.ts | 43 +------------------------------ 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/src/utils/PlatformServiceMixin.ts b/src/utils/PlatformServiceMixin.ts index 39b40afe..3a6ac7f2 100644 --- a/src/utils/PlatformServiceMixin.ts +++ b/src/utils/PlatformServiceMixin.ts @@ -236,45 +236,6 @@ export const PlatformServiceMixin = { } }, - /** - * Check if active identity needs user intervention - * Returns true if active_identity table is empty but accounts exist - * This allows components to show appropriate UI for user selection - */ - async $needsActiveIdentitySelection(): Promise { - try { - // Check if active_identity table has a valid activeDid - const activeIdentity = await this.$dbQuery( - "SELECT activeDid FROM active_identity WHERE id = 1", - ); - - const currentActiveDid = activeIdentity?.values?.[0]?.[0] as string; - - // If we have an activeDid, validate it exists in accounts - if (currentActiveDid) { - const accountExists = await this.$dbQuery( - "SELECT did FROM accounts WHERE did = ?", - [currentActiveDid], - ); - return !accountExists?.values?.length; - } - - // If no activeDid, check if there are any accounts available - const availableAccounts = await this.$dbQuery( - "SELECT COUNT(*) FROM accounts", - ); - const accountCount = availableAccounts?.values?.[0]?.[0] as number; - - return accountCount > 0; - } catch (error) { - logger.error( - "[PlatformServiceMixin] Error checking if active identity selection needed:", - error, - ); - return false; - } - }, - /** * Get available account DIDs for user selection * Returns array of DIDs that can be set as active identity @@ -722,7 +683,7 @@ export const PlatformServiceMixin = { "[PlatformServiceMixin] Active identity not found in accounts, clearing", ); await this.$dbExec( - "UPDATE active_identity SET activeDid = '', lastUpdated = datetime('now') WHERE id = 1", + "UPDATE active_identity SET activeDid = NULL, lastUpdated = datetime('now') WHERE id = 1", ); return { activeDid: "" }; } @@ -1975,7 +1936,6 @@ export interface IPlatformServiceMixin { ): Promise; $getActiveIdentity(): Promise<{ activeDid: string }>; $withTransaction(callback: () => Promise): Promise; - $needsActiveIdentitySelection(): Promise; $getAvailableAccountDids(): Promise; isCapacitor: boolean; isWeb: boolean; @@ -2100,7 +2060,6 @@ declare module "@vue/runtime-core" { ): Promise; $getActiveIdentity(): Promise<{ activeDid: string }>; $withTransaction(fn: () => Promise): Promise; - $needsActiveIdentitySelection(): Promise; $getAvailableAccountDids(): Promise; // Specialized shortcuts - contacts cached, settings fresh