SilentNotes icon indicating copy to clipboard operation
SilentNotes copied to clipboard

Allow linking pictures in notes

Open X-Ryl669 opened this issue 4 years ago • 9 comments

It would be very useful if the application allowed importing a photo from the current gallery to insert in note (and even better, a small audio clip for recorded voice note)

X-Ryl669 avatar Apr 17 '21 20:04 X-Ryl669

This would be a nice feature and it is occasionally requested. It is well possible that support of attachements will be implemented in future, but let me explain why it is not so easy to do. It's a bit technical but nevertheless it should give some insight into the problems, a simple app like SilentNotes has to face.

Centralized apps which store the notes on their own servers, with server side code under their own control, can easily handle transactions. If a synchronization fails, a database can rollback all changes (notes and attachements) and get back to a valid state. If several devices sync at the same time, the transaction guarantees a serialization of the syncs.

SilentNotes on the other hand uses self hosting with WebDav, FTP or cloud services like OneDrive. There is no need to install code on server side, the server is not controlled by the app, and the protocols do not offer transaction handling. This makes it difficult to guarantee a valid state without loss of information.

Another problem is the clean-up of attachements when not used anymore. SilentNotes can only find out whether attachements are abandoned, as long as the safe is open and the content is decrypted (not at the moment of syncing). If you delete an encrypted note, SilentNotes cannot easily detect whether there is an attachement to remove, and other devices could still refer to it. For notes this is solved by maintaining a list of ids of all deleted notes.

That said, it is not impossible to implement, but I hope you understand why it needs some time.

martinstoeckli avatar Apr 18 '21 13:04 martinstoeckli

What about using data-url ? That way, there's no separate file to save and as such, no complex synchronization handling. It's using 33% more size for base64 encoding, but I don't think it's an issue.

X-Ryl669 avatar Apr 18 '21 16:04 X-Ryl669

Yes including the pictures inside the repository (which is zipped before the encryption/sync anyway) would clearly solve the synchronisation problem, but it doesn't scale. With a few pictures you will quickly get up to 10MB, which can become a problem if you have to download it every time you startup the app. Even more of a problem is the upload, in case there are modifications on the notes, especially with a mobile data connection it would get slower and slower.

For me this is not an option, it is simply not necessary to up-/download the attachements every time, especially since they are immutable and never change. On the other hand, a proper handling must be possible and I will head for it.

martinstoeckli avatar Apr 19 '21 15:04 martinstoeckli

What if you cache the photos on the phone, and only update them if they change. Would that be feasable? Is there any estimation for tjis feature? The app has great potential, but it's missing this important feature.

SilentNotes always has a local copy of the notes/attachements, this is how the app works (one can work offline without internet connection). So this caching of encrypted attachements would be done in any case, the crucial point is whether a transaction has to handle multiple or a single file, cached attachements means that multiple files are involved.

At the moment I'm working hard at replacing the editor with ProseMirror , it allows for more features and it seems to run more stable. This is much of work and has priority at the moment, thus I cannot promise any date yet.

martinstoeckli avatar May 20 '22 11:05 martinstoeckli

I'm currently extracting the synchronization into a background service, which can stay alive a bit longer than the app itself on Android. This is a precondition of a reliable synchronization of multiple files. https://github.com/martinstoeckli/SilentNotes/tree/feature/sync-background-service2

martinstoeckli avatar Mar 17 '23 10:03 martinstoeckli