1+ import log from 'electron-log' ;
12import type { Account , AuthState } from '../../types' ;
23import Constants from '../constants' ;
34import { loadState , saveState } from '../storage' ;
45import { getUserData } from './utils' ;
56
6- export function logMigrationProgress ( msg : string ) {
7- // biome-ignore lint/suspicious/noConsoleLog: log migration progress
8- console . log ( `Account Migration: ${ msg } ` ) ;
9- }
10-
117/**
128 * Migrate authenticated accounts from old data structure to new data structure (v5.7.0+).
139 *
@@ -16,17 +12,20 @@ export function logMigrationProgress(msg: string) {
1612export async function migrateAuthenticatedAccounts ( ) {
1713 const existing = loadState ( ) ;
1814
19- if ( hasAccountsToMigrate ( existing . auth ) ) {
20- logMigrationProgress ( 'Commencing authenticated accounts migration' ) ;
15+ if ( ! hasAccountsToMigrate ( existing . auth ) ) {
16+ log . info ( 'Account Migration: No accounts need migrating' ) ;
17+ return ;
18+ }
19+
20+ log . info ( 'Account Migration: Commencing authenticated accounts migration' ) ;
2121
22- const migratedAccounts = await convertAccounts ( existing . auth ) ;
22+ const migratedAccounts = await convertAccounts ( existing . auth ) ;
2323
24- saveState ( {
25- auth : { ...existing . auth , accounts : migratedAccounts } ,
26- settings : existing . settings ,
27- } ) ;
28- logMigrationProgress ( 'Authenticated accounts migration complete' ) ;
29- }
24+ saveState ( {
25+ auth : { ...existing . auth , accounts : migratedAccounts } ,
26+ settings : existing . settings ,
27+ } ) ;
28+ log . info ( 'Account Migration: Authenticated accounts migration complete' ) ;
3029}
3130
3231export function hasAccountsToMigrate ( existingAuthState : AuthState ) : boolean {
0 commit comments