Closed sonnyp closed 1 year ago
thanks for the suggestions. I'll implement saving in multiple files.
I'm not sure about saving on every keystroke as it may not be desirable for SSDs (limited writes), but the limitations are too high so I'll implement it anyways...
It doesn't have to be on every keystroke. It could be when focus is lost. Or debounced.
how to i detect when focus is lost?
I would use this https://docs.gtk.org/gtk4/method.TextBuffer.set_modified.html
This is what Workbench uses in case you're looking for an example.
oh okay!
so in short, when I save the note, I'll set the modified
bit to false
, then when it's changed it'll emit the modified-changed
signal?
yes! this will save on every change but wait for the async save operation to be done before calling the next one
This is what Text Editor and Builder are doing too IIRC
there is also a way to make Gio use a backup file before replacing
If you assign me to a PR I can have a quick look / review if you like
well I can definitely put up something like tomorrow. but if you want/can, you can create a PR
The app saves data on quit. This is problematic because if it crashes or if it is terminated unexpected (by user or system) - notes/changes won't be saved. My suggestion is to save changes as they happen.
Thank you for this analysis, now at least I know why I lost everything from my first day of use: I shut down my computer without manually quitting the application. Since I have a lot of applications open, the system probably terminated it.
Congrats on the app – it looks and feels great.
I have concerns about how the app persists data.
The app saves data on quit. This is problematic because if it crashes or if it is terminated unexpected (by user or system) - notes/changes won't be saved. My suggestion is to save changes as they happen.
The app saves all notes in a single JSON file. If something goes wrong during writing, the file will not be parsable and all notes will essentially be lost to users. My suggestion is to use one file per note.