-
-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
simon/better draft api in jsonrpc #6426
base: main
Are you sure you want to change the base?
Conversation
…ct`, `draft_set_quoted_message`, `draft_set_quoted_text`
message.set_text(text); | ||
message | ||
.get_chat_id() | ||
.set_draft(&ctx, Some(&mut message)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit ugly that this function sets the draft, so if there are concurrent calls to e.g. draft_set_text
and draft_set_subject
, only one will be applied.
Maybe better manage the draft in the UI and call only create_draft
and some sort of "send message" API that sends the draft passed from the UI as a whole and resets the draft?
The idea of managing the draft on the core side and updating it does not look like a good API to me, it's just how it is historically.
If we at some point make it possible to connect to remote core, managing the draft over high-latency JSON-RPC connection is going to be even worse.
Less stateful API could be like this:
If there are concurrent calls to |
create_draft
,draft_set_text
,draft_set_subject
,draft_set_quoted_message
,draft_set_quoted_text
misc_set_draft
andmisc_send_draft
Still a work in progress. Preparation for Composer refactoring in desktop.
Why did I choose that message id instead of just using the current draft based on chat id?
Because using the message id is more robust and has less potential for unexpected behaviour, since the UI always knows what message it is editing or sending because of the message id. The motto is: don't rely on global state.
closes #4643