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

Changes lost if running in multiple tabs/windows and don't refresh first #19

Open
codingthat opened this issue Feb 20, 2023 · 3 comments

Comments

@codingthat
Copy link
Contributor

Hey, something small and reproducible for once ;)

v1.6.1

  1. Mark task A complete in browser 1
  2. Open browser 2 where mindstream was a saved tab
  3. In browser 2, don't refresh; you can see task A is still incomplete; don't touch it
  4. In browser 2, add task B
  5. In browser 1, refresh; task A is now incomplete

So the stale state from browser 2 becomes current again because browser 2 wasn't refreshed first.

This is also true if browser 2 was already opened and just not refreshed lately.

Perhaps whenever receiving the focus, or maybe on any user action, the file timestamp could be checked and a refresh forced only if todo.txt seems to have been modified since we last modified it (implying another tab or CLI or manual edit modified it).

I often use mindstream in multiple tabs because it's nice to have one-click access to multiple views by project/context/etc. More specifically, it's nice to keep a mindstream tab filtered by the relevant project beside other tabs relevant to the project, all in the same browser window.

Same goes for doing cleanup in a text editor though. Either way you have to remember to refresh in every browser tab, otherwise you risk losing all your changes and have to redo them.

@codingthat
Copy link
Contributor Author

I see this was already implemented at

const FILE_WATCH_INTERVAL = 60 * 1000
. Maybe 60s is too long for my use case, since I often enough switch projects to jot down a new idea/todo within a minute of the last update from the previous context?

Is there any danger to making it check every 500ms? Or is it better to trigger an immediate check when the tab receives focus?

@codingthat
Copy link
Contributor Author

codingthat commented Feb 20, 2023

500 ms seems to work OK here (with just 2 tabs, anyway), for what it's worth. Definitely solves the above issue, at least. ✔

@xuhcc
Copy link
Owner

xuhcc commented Feb 20, 2023

I would change it to 5s first, to see how this affects performance

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

No branches or pull requests

2 participants