diff --git a/packages/bruno-electron/src/app/onboarding.js b/packages/bruno-electron/src/app/onboarding.js index 5c9e4a492..de7b575e2 100644 --- a/packages/bruno-electron/src/app/onboarding.js +++ b/packages/bruno-electron/src/app/onboarding.js @@ -77,11 +77,12 @@ async function onboardUser(mainWindow, lastOpenedCollections) { } if (process.env.DISABLE_SAMPLE_COLLECTION_IMPORT !== 'true') { - // Onboarding was added later; - // if a collection already exists, user is old → skip onboarding + // Check if user already has collections (indicates they're an existing user) + // Onboarding was added in a later version, so for existing users we should skip it + // to avoid creating sample collections const collections = await lastOpenedCollections.getAll(); if (collections.length > 0) { - preferencesUtil.markAsLaunched(); + await preferencesUtil.markAsLaunched(); return; } @@ -89,11 +90,11 @@ async function onboardUser(mainWindow, lastOpenedCollections) { await importSampleCollection(collectionLocation, mainWindow, lastOpenedCollections); } - preferencesUtil.markAsLaunched(); + await preferencesUtil.markAsLaunched(); } catch (error) { console.error('Failed to handle onboarding:', error); // Still mark as launched to prevent retry on next startup - preferencesUtil.markAsLaunched(); + await preferencesUtil.markAsLaunched(); } } diff --git a/packages/bruno-electron/src/store/preferences.js b/packages/bruno-electron/src/store/preferences.js index 44600907a..004d0e860 100644 --- a/packages/bruno-electron/src/store/preferences.js +++ b/packages/bruno-electron/src/store/preferences.js @@ -186,10 +186,15 @@ const preferencesUtil = { hasLaunchedBefore: () => { return get(getPreferences(), 'onboarding.hasLaunchedBefore', false); }, - markAsLaunched: () => { + markAsLaunched: async () => { const preferences = getPreferences(); preferences.onboarding.hasLaunchedBefore = true; - preferencesStore.savePreferences(preferences); + + try { + await savePreferences(preferences); + } catch (err) { + console.error('Failed to save preferences in markAsLaunched:', err); + } } };