feat(GlobalStateStore): prevent saving during initial load
This commit is contained in:
@@ -301,6 +301,9 @@ const GlobalStateStore = createStore<GlobalStateStoreType>((set, get) => ({
|
||||
...createComplexActions(set, get),
|
||||
}));
|
||||
|
||||
// Flag to prevent saving during initial load
|
||||
let isInitialLoad = true;
|
||||
|
||||
loadStorage()
|
||||
.then((state) => {
|
||||
GlobalStateStore.setState((current) => ({
|
||||
@@ -316,9 +319,18 @@ loadStorage()
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error('Error loading storage:', e);
|
||||
})
|
||||
.finally(() => {
|
||||
// Enable saving after initial load completes
|
||||
isInitialLoad = false;
|
||||
});
|
||||
|
||||
GlobalStateStore.subscribe((state) => {
|
||||
// Skip saving during initial load
|
||||
if (isInitialLoad) {
|
||||
return;
|
||||
}
|
||||
|
||||
saveStorage(state).catch((e) => {
|
||||
console.error('Error saving storage:', e);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user