From ca70a4f6810613ee40ecf7afc31127d233f4831e Mon Sep 17 00:00:00 2001 From: Jean Brito Date: Fri, 10 Nov 2023 14:34:33 -0300 Subject: [PATCH] add persistence debounce back --- src/app/main/persistence.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/app/main/persistence.ts b/src/app/main/persistence.ts index 53f5e22d8..9a6898fb7 100644 --- a/src/app/main/persistence.ts +++ b/src/app/main/persistence.ts @@ -28,16 +28,15 @@ const getElectronStore = (): ElectronStore => { 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(); - // } };