TiddlyWiki / TiddlyWiki5

A self-contained JavaScript wiki for the browser, Node.js, AWS Lambda etc.
https://tiddlywiki.com/
Other
7.99k stars 1.18k forks source link

[IDEA] Autosave frequency throttle #6979

Open simonbaird opened 1 year ago

simonbaird commented 1 year ago

Is your feature request related to a problem? Please describe.

I suspect that some brand new TiddlyWiki users on https://tiddlyhost.com don't realize they need to hit the save button to save their changes. I'd like to enable autosave for that reason, but with a throttle so that it autosaves only when it's more than (say) two minutes since the last save.

Describe the solution you'd like

I'm imagining a new configuration option related to autosave, called something like "Minimum seconds between autosaves" or "Autosave throttle (minimum seconds between autosaves)". The value would be an integer number of seconds stored in a tiddler named $:/config/AutoSavePeriod or something like that.

The Autosave mechanism would change so if that value is present and non-zero it would not trigger an autosave until the time since the last save is more than the threshold. Of course multiple autosave triggers would need to not queue up, so when the time comes only one save event happens.

Not sure if it would be distracting or not, but it could also maybe show a countdown timer somewhere, so the user can see how many seconds there are until the autosave happens.

Describe alternatives you've considered

My current workaround is to disable autosave on Tiddlyhost since I don't want every single change to trigger a save. The reasoning there is that: a). I think it would create a significantly higher load on Tiddlyhost's server, and b). since Tiddlyhost does a full file save every time there's a wait between "Save started..." and "Save complete". This is a bad UX at best and at worst it could result in race condition problems where different save request are happening at the same time.

I think this idea would be generally useful, rather than being a feature just for Tiddlyhost, so that's why I'm suggesting it as a TiddlyWiki feature.

Additional context

There may be some overlap with #6684 here.

Actually I'm not 100% this feature doesn't exist already, so please let me know this can be done already, or if there's a well known plugin that can do it.

simonbaird commented 1 year ago

Hypothetically, if I did some work on implementing this feature, would it be considered for merge?

Jermolene commented 1 year ago

Hi @simonbaird sorry for the delay, that's a great idea, and a PR would be appreciated.

simonbaird commented 1 year ago

I noticed there's something on TiddlyTools that might be relevant here, see https://tiddlytools.com/#TiddlyTools%2FTime%2FAutoSaver .

saqimtiaz commented 7 months ago

I have taken a quick crack at an implementation in #7995

For testing, use the vercel preview at https://tiddlywiki5-axn1shmq4-jermolene.vercel.app/

I definitely think there needs to be some affordance for the user to know that an autosave is queued and will take place without needing any further user interaction.