From 4ab306b5e2aad487ad28d7874455b370ec97010f Mon Sep 17 00:00:00 2001 From: Chris White Date: Mon, 15 Jan 2024 13:26:41 -0500 Subject: [PATCH] Add new autoremember-timer-minutes setting (#316) [WIP] autoremember timer --- app/common/setting-definitions.js | 6 ++++++ app/settings/manifest.js | 9 +++++++++ app/win/main_tl.js | 14 ++++++++++++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/app/common/setting-definitions.js b/app/common/setting-definitions.js index 4d56525..b7c0a4f 100644 --- a/app/common/setting-definitions.js +++ b/app/common/setting-definitions.js @@ -174,6 +174,12 @@ _VAL[_NAM.CFGS_FAVICON_SOURCE] = (v)=>{ return (( v === FAVICON_SITE || v === FAVICON_CHROME || v === FAVICON_DDG ) ? v : undefined); }; +// #316. How often to autosave. Empty or <= 0 == don't autosave +_NAM.CFGS_AUTOREMEMBER_MINUTES = 'autoremember-timer-minutes'; +_DEF[_NAM.CFGS_AUTOREMEMBER_MINUTES] = ''; +_VAL[_NAM.CFGS_AUTOREMEMBER_MINUTES] = _vint; + + // }}}2 /// The default values for the configuration settings. diff --git a/app/settings/manifest.js b/app/settings/manifest.js index 7c8e478..90e9d9e 100644 --- a/app/settings/manifest.js +++ b/app/settings/manifest.js @@ -216,6 +216,15 @@ setting_definitions.push( "type": "checkbox", "label": future_i18n('Prompt for confirmation before closing or deleting a tab that is currently playing audio ()'), }, + { + "tab": future_i18n("Behaviour"), + "group": future_i18n("Autosave"), + "name": S.S_AUTOREMEMBER_MINUTES, + "type": "text", + "label": future_i18n('If this is an integer I >= 0, automatically ' + + 'remember all open windows/tabs every I minutes. Refresh the ' + + 'TabFern window to apply changes to this option.'), + }, // Appearance { diff --git a/app/win/main_tl.js b/app/win/main_tl.js index 3b43a3d..270cda0 100644 --- a/app/win/main_tl.js +++ b/app/win/main_tl.js @@ -4301,6 +4301,14 @@ function addEventListeners(done) done(); } //addEventListeners +function startAutoRememberTimerIfRequested(done) { + const minutes = S.getInt(S.S_AUTOREMEMBER_MINUTES, 0); + if(minutes > 0) { + // TODO RESUME HERE --- start timer + } + done(); +} // startAutoRememberTimerIfRequested() + /// The last function to be called after all other initialization has /// completed successfully. function initTreeFinal(done) @@ -4439,9 +4447,9 @@ function main() }) .then(addOpenWindowsToTree) .then(addEventListeners) - .then(initTreeFinal) + .then(initTreeFinal) // This needs to be the last real init step - .val(check_init_step_count) + .val(check_init_step_count) // This is a sanity check after initTreeFinal // Stop the spinner, if it started .val(()=>{ @@ -4450,6 +4458,8 @@ function main() //clearTimeout(spin_timer); }) + .then(startAutoRememberTimerIfRequested) + .or((err)=>{ $(K.INIT_MSG_SEL).text( $(K.INIT_MSG_SEL).text() + "\n" + err