matrix-rust-sdk icon indicating copy to clipboard operation
matrix-rust-sdk copied to clipboard

Store drafts for each room so that clients can restore them at a later time

Open Velin92 opened this issue 1 year ago • 5 comments

We should store message drafts in the local encrypted store for security reason, so that clients can save them and restore them at a later time. We should store drafts in a dictionary using the room IDs to which the draft belongs as a key. The draft should consist in a simple struct that sores the plain text, an optional html text in case the message is using rich text formatting, and if the draft is a normal message, a reply or an edit (the latter two should also store the event ID they are replying/editing) We should then expose bindings to save and restore the draft given the room ID.

Velin92 avatar May 17 '24 10:05 Velin92

It's not the first time feature requests like this are done.

I guess the solution is to expose an encrypted key/value store dedicated only to the app. What do you think @Velin92?

Hywan avatar May 22 '24 15:05 Hywan

cc @stefanceriu too

Hywan avatar May 22 '24 15:05 Hywan

I suggested we handle it exactly the same as breadcrumbs (https://github.com/matrix-org/matrix-rust-sdk/pull/3293) and the user avatar url before it i.e. introduce a new StateStoreDataKey and build a simple API on top of it to expose to the final client akin to track_recently_visited_room/get_recently_visited_rooms. Using methods instead of exposing the full key value store allows us to put part of the logic on the SDK side and test it accordingly.

stefanceriu avatar May 22 '24 15:05 stefanceriu

I forgot about breadcrumb and I believe that's a good strategy to reproduce.

Hywan avatar May 22 '24 15:05 Hywan

I already have a simple PR opened for it https://github.com/matrix-org/matrix-rust-sdk/pull/3439

Velin92 avatar May 23 '24 07:05 Velin92

closing since we handled the APIs in the following PR: https://github.com/matrix-org/matrix-rust-sdk/pull/3534

However will open another issue to address the fact that as of right now is impossible to send a reply or an edit for an event that has not been paginated yet in the timeline

Velin92 avatar Jun 12 '24 16:06 Velin92