Skip to content

Commit

Permalink
add persistence debounce back
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanfbrito committed Nov 10, 2023
1 parent c837459 commit ca70a4f
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/app/main/persistence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,15 @@ const getElectronStore = (): ElectronStore<PersistableValues> => {
export const getPersistedValues = (): PersistableValues =>
getElectronStore().store;

// let lastSavedTime = 0;
let lastSavedTime = 0;

export const persistValues = (values: PersistableValues): void => {
// console.log('persistValues', values);
// if (Date.now() - lastSavedTime > 1000) {
try {
getElectronStore().set(values);
} catch (error) {
error instanceof Error && console.error(error);
if (Date.now() - lastSavedTime > 1000) {
try {
getElectronStore().set(values);
} catch (error) {
error instanceof Error && console.error(error);
}
lastSavedTime = Date.now();
}
// lastSavedTime = Date.now();
// }
};

0 comments on commit ca70a4f

Please sign in to comment.