Skip to content

Commit

Permalink
Add new autoremember-timer-minutes setting (#316)
Browse files Browse the repository at this point in the history
[WIP] autoremember timer
  • Loading branch information
cxw42 committed Jan 15, 2024
1 parent 40dddff commit 4ab306b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
6 changes: 6 additions & 0 deletions app/common/setting-definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions app/settings/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (<i class="fa fa-music"></i>)'),
},
{
"tab": future_i18n("Behaviour"),
"group": future_i18n("Autosave"),
"name": S.S_AUTOREMEMBER_MINUTES,
"type": "text",
"label": future_i18n('If this is an integer <i>I</i> &gt;= 0, automatically '
+ 'remember all open windows/tabs every <i>I</i> minutes. Refresh the '
+ 'TabFern window to apply changes to this option.'),
},

// Appearance
{
Expand Down
14 changes: 12 additions & 2 deletions app/win/main_tl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(()=>{
Expand All @@ -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
Expand Down

0 comments on commit 4ab306b

Please sign in to comment.