Store drafts for each room so that clients can restore them at a later time
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.
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?
cc @stefanceriu too
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.
I forgot about breadcrumb and I believe that's a good strategy to reproduce.
I already have a simple PR opened for it https://github.com/matrix-org/matrix-rust-sdk/pull/3439
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