@ -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 || "" ;
/ / U s e n e w f a ç a d e m e t h o d w i t h l e g a c y f a l l b a c k
this . activeDid = ( await this . $getActiveDid ( ) ) || "" ;
this . apiServer = settings . apiServer || "" ;
this . apiServerInput = settings . apiServer || "" ;
@ -221,12 +223,21 @@ export default class IdentitySwitcherView extends Vue {
}
}
async switchAccount ( did ? : string ) {
/ / S a v e t h e n e w a c t i v e D I D t o m a s t e r s e t t i n g s
async switchIdentity ( did ? : string ) {
try {
if ( did ) {
/ / U s e n e w f a ç a d e m e t h o d i n s t e a d o f l e g a c y s e t t i n g s
await this . $setActiveDid ( did ) ;
/ / U p d a t e l o c a l s t a t e
this . activeDid = did ;
/ / L e g a c y f a l l b a c k - r e m o v e a f t e r P h a s e C
if ( ! FLAGS . USE_ACTIVE_IDENTITY_ONLY ) {
await this . $saveSettings ( { activeDid : did } ) ;
}
/ / C h e c k i f w e n e e d t o l o a d u s e r - s p e c i f i c s e t t i n g s f o r t h e n e w D I D
if ( did ) {
try {
const newSettings = await this . $accountSettings ( did ) ;
logger . info (
@ -250,6 +261,10 @@ export default class IdentitySwitcherView extends Vue {
) ;
/ / H a n d l e e r r o r s i l e n t l y - u s e r s e t t i n g s w i l l b e l o a d e d w h e n n e e d e d
}
} else {
/ / H a n d l e " N o I d e n t i t y " c a s e
this . activeDid = "" ;
/ / N o t e : W e d o n ' t c l e a r a c t i v e D I D i n d a t a b a s e f o r s a f e t y
}
logger . info (
@ -261,6 +276,10 @@ export default class IdentitySwitcherView extends Vue {
/ / N a v i g a t e t o h o m e p a g e t o t r i g g e r t h e w a t c h e r
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 ) {