|
|
@ -46,7 +46,7 @@ |
|
|
|
<div class="flex items-center justify-between mb-2"> |
|
|
|
<div |
|
|
|
:class="identityListItemClasses" |
|
|
|
@click="switchAccount(ident.did)" |
|
|
|
@click="switchIdentity(ident.did)" |
|
|
|
> |
|
|
|
<font-awesome |
|
|
|
v-if="ident.did === activeDid" |
|
|
@ -94,7 +94,7 @@ |
|
|
|
<a |
|
|
|
href="#" |
|
|
|
:class="secondaryButtonClasses" |
|
|
|
@click="switchAccount(undefined)" |
|
|
|
@click="switchIdentity(undefined)" |
|
|
|
> |
|
|
|
No Identity |
|
|
|
</a> |
|
|
@ -116,6 +116,7 @@ import { |
|
|
|
NOTIFY_DELETE_IDENTITY_CONFIRM, |
|
|
|
} from "@/constants/notifications"; |
|
|
|
import { Account } from "@/db/tables/accounts"; |
|
|
|
import { FLAGS } from "@/config/featureFlags"; |
|
|
|
|
|
|
|
@Component({ |
|
|
|
components: { QuickNav }, |
|
|
@ -200,7 +201,8 @@ export default class IdentitySwitcherView extends Vue { |
|
|
|
async created() { |
|
|
|
try { |
|
|
|
const settings = await this.$accountSettings(); |
|
|
|
this.activeDid = settings.activeDid || ""; |
|
|
|
// Use new façade method with legacy fallback |
|
|
|
this.activeDid = (await this.$getActiveDid()) || ""; |
|
|
|
this.apiServer = settings.apiServer || ""; |
|
|
|
this.apiServerInput = settings.apiServer || ""; |
|
|
|
|
|
|
@ -221,46 +223,63 @@ export default class IdentitySwitcherView extends Vue { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
async switchAccount(did?: string) { |
|
|
|
// Save the new active DID to master settings |
|
|
|
await this.$saveSettings({ activeDid: did }); |
|
|
|
async switchIdentity(did?: string) { |
|
|
|
try { |
|
|
|
if (did) { |
|
|
|
// Use new façade method instead of legacy settings |
|
|
|
await this.$setActiveDid(did); |
|
|
|
|
|
|
|
// Check if we need to load user-specific settings for the new DID |
|
|
|
if (did) { |
|
|
|
try { |
|
|
|
const newSettings = await this.$accountSettings(did); |
|
|
|
logger.info( |
|
|
|
"[IdentitySwitcher Settings Trace] ✅ New account settings loaded", |
|
|
|
{ |
|
|
|
did, |
|
|
|
settingsKeys: Object.keys(newSettings).filter( |
|
|
|
(k) => |
|
|
|
k in newSettings && |
|
|
|
newSettings[k as keyof typeof newSettings] !== undefined, |
|
|
|
), |
|
|
|
}, |
|
|
|
); |
|
|
|
} catch (error) { |
|
|
|
logger.warn( |
|
|
|
"[IdentitySwitcher Settings Trace] ⚠️ Error loading new account settings", |
|
|
|
{ |
|
|
|
did, |
|
|
|
error: error instanceof Error ? error.message : String(error), |
|
|
|
}, |
|
|
|
); |
|
|
|
// Handle error silently - user settings will be loaded when needed |
|
|
|
// Update local state |
|
|
|
this.activeDid = did; |
|
|
|
|
|
|
|
// Legacy fallback - remove after Phase C |
|
|
|
if (!FLAGS.USE_ACTIVE_IDENTITY_ONLY) { |
|
|
|
await this.$saveSettings({ activeDid: did }); |
|
|
|
} |
|
|
|
|
|
|
|
// Check if we need to load user-specific settings for the new DID |
|
|
|
try { |
|
|
|
const newSettings = await this.$accountSettings(did); |
|
|
|
logger.info( |
|
|
|
"[IdentitySwitcher Settings Trace] ✅ New account settings loaded", |
|
|
|
{ |
|
|
|
did, |
|
|
|
settingsKeys: Object.keys(newSettings).filter( |
|
|
|
(k) => |
|
|
|
k in newSettings && |
|
|
|
newSettings[k as keyof typeof newSettings] !== undefined, |
|
|
|
), |
|
|
|
}, |
|
|
|
); |
|
|
|
} catch (error) { |
|
|
|
logger.warn( |
|
|
|
"[IdentitySwitcher Settings Trace] ⚠️ Error loading new account settings", |
|
|
|
{ |
|
|
|
did, |
|
|
|
error: error instanceof Error ? error.message : String(error), |
|
|
|
}, |
|
|
|
); |
|
|
|
// Handle error silently - user settings will be loaded when needed |
|
|
|
} |
|
|
|
} else { |
|
|
|
// Handle "No Identity" case |
|
|
|
this.activeDid = ""; |
|
|
|
// Note: We don't clear active DID in database for safety |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
logger.info( |
|
|
|
"[IdentitySwitcher Settings Trace] 🔄 Navigating to home to trigger watcher", |
|
|
|
{ |
|
|
|
newDid: did, |
|
|
|
}, |
|
|
|
); |
|
|
|
logger.info( |
|
|
|
"[IdentitySwitcher Settings Trace] 🔄 Navigating to home to trigger watcher", |
|
|
|
{ |
|
|
|
newDid: did, |
|
|
|
}, |
|
|
|
); |
|
|
|
|
|
|
|
// Navigate to home page to trigger the watcher |
|
|
|
this.$router.push({ name: "home" }); |
|
|
|
// Navigate to home page to trigger the watcher |
|
|
|
this.$router.push({ name: "home" }); |
|
|
|
} catch (error) { |
|
|
|
logger.error("[IdentitySwitcher] Error switching identity", error); |
|
|
|
this.notify.error("Error switching identity", TIMEOUTS.SHORT); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
async deleteAccount(id: string) { |
|
|
|