mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-15 11:51:30 +00:00
fix: update preferences saving method in preferences utility (#5617)
* fix: update preferences saving method in preferences utility * fix: make markAsLaunched asynchronous and improve error handling in onboarding process * fix: lint errors --------- Co-authored-by: Bijin Bruno <bijin@usebruno.com>
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user