Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto save files after timeout #146

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

joshuamegnauth54
Copy link
Contributor

@joshuamegnauth54 joshuamegnauth54 commented Mar 3, 2024

This patch implements an optional auto saver that saves changes after N seconds after the last change.

Closes: #230

Example with a timeout of two seconds:

  1. The user types and then stops. After two seconds, those changes will be automatically saved.
  2. The user types for ten seconds straight. The file is not auto saved at all within those ten seconds, but it will be auto saved on the 12th second.

At the moment, this PR only targets a basic, working implementation. Future patches should revise this to be more in line with #94 by saving the changes in a back up file instead of overwriting the contents of the working file.

Tasks:

  • Implement a system to await multiple timeouts that fires messages when said timeouts are hit
  • Wire up that system to the app's subscriptions
  • Register or remove timeouts on relevant tab messages
  • UI option to enable auto saver

The app must register modified tabs to be autosaver as well as remove
cancelled tabs. With this commit, the autosaver is functional.

Todo:
* Config option for the save timeout
* Remove the asterisk for saved tabs
* Clean up and dedupe
@joshuamegnauth54
Copy link
Contributor Author

I have everything working if anyone wants to try it out. I still have to clean up the code a bit and add an option to enable autosaving.

* New message to update the base timeout for the autosaver
* Improve ergonomics for registering timeouts from the app
* Update tab names after auto save
* Register tabs when auto saver is enabled via settings
* Unregister tabs when auto saver is disabled
@joshuamegnauth54
Copy link
Contributor Author

I'll rebase this on main and ensure it still works soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Autosave Toggle for COSMIC Text Editor
1 participant