@@ -28,6 +28,7 @@ import {
2828 type Status ,
2929 type SystemSettingsState ,
3030 Theme ,
31+ type Token ,
3132} from '../types' ;
3233import type { Notification } from '../typesGitHub' ;
3334import { headNotifications } from '../utils/api/client' ;
@@ -44,6 +45,8 @@ import {
4445 removeAccount ,
4546} from '../utils/auth/utils' ;
4647import {
48+ decryptValue ,
49+ encryptValue ,
4750 setAlternateIdleIcon ,
4851 setAutoLaunch ,
4952 setKeyboardShortcut ,
@@ -281,20 +284,45 @@ export const AppProvider = ({ children }: { children: ReactNode }) => {
281284 if ( existing . settings ) {
282285 setKeyboardShortcut ( existing . settings . keyboardShortcut ) ;
283286 setAlternateIdleIcon ( existing . settings . useAlternateIdleIcon ) ;
284- setSettings ( { ...defaultSettings , ...existing . settings } ) ;
287+ setSettings ( {
288+ ...defaultSettings ,
289+ ...Object . fromEntries (
290+ Object . entries ( existing . settings ) . filter (
291+ ( [ key ] ) => key in defaultSettings ,
292+ ) ,
293+ ) ,
294+ } ) ;
285295 webFrame . setZoomLevel (
286296 zoomPercentageToLevel ( existing . settings . zoomPercentage ) ,
287297 ) ;
288298 }
289299
290300 if ( existing . auth ) {
291- setAuth ( { ...defaultAuth , ...existing . auth } ) ;
301+ setAuth ( {
302+ ...defaultAuth ,
303+ ...Object . fromEntries (
304+ Object . entries ( existing . auth ) . filter ( ( [ key ] ) => key in defaultAuth ) ,
305+ ) ,
306+ } ) ;
292307
293308 // Refresh account data on app start
294309 for ( const account of existing . auth . accounts ) {
310+ /**
311+ * Check if each account has an encrypted token.
312+ * If not encrypt it and save it.
313+ */
314+ try {
315+ await decryptValue ( account . token ) ;
316+ } catch ( err ) {
317+ const encryptedToken = await encryptValue ( account . token ) ;
318+ account . token = encryptedToken as Token ;
319+ }
320+
295321 await refreshAccount ( account ) ;
296322 }
297323 }
324+
325+ // saveState({ auth: existing.auth, settings });
298326 } , [ ] ) ;
299327
300328 const fetchNotificationsWithAccounts = useCallback (
0 commit comments