()
| 25 | let migrationPromise: Promise<void> | null = null |
| 26 | |
| 27 | async function migrateFromLocalStorage(): Promise<void> { |
| 28 | if (typeof window === 'undefined') return |
| 29 | |
| 30 | try { |
| 31 | const migrated = await get<boolean>(MIGRATION_KEY) |
| 32 | if (migrated) return |
| 33 | |
| 34 | const localData = localStorage.getItem(STORE_KEY) |
| 35 | if (localData) { |
| 36 | await set(STORE_KEY, localData) |
| 37 | localStorage.removeItem(STORE_KEY) |
| 38 | logger.info('Migrated console store to IndexedDB') |
| 39 | } |
| 40 | |
| 41 | await set(MIGRATION_KEY, true) |
| 42 | } catch (error) { |
| 43 | logger.warn('Migration from localStorage failed', { error }) |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | if (typeof window !== 'undefined') { |
| 48 | migrationPromise = migrateFromLocalStorage().finally(() => { |
no test coverage detected