xuhcc / mindstream

Task management app, built on todo.txt.
GNU General Public License v3.0
41 stars 6 forks source link

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

Open codingthat opened 1 year ago

codingthat commented 1 year ago

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 commented 1 year ago

I see this was already implemented at https://github.com/xuhcc/mindstream/blob/858f506f6e0849950e88b3cf318a6cf7b17b64a5/src/app/shared/todo-file.service.ts#L12 . 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 commented 1 year ago

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 commented 1 year ago

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