-
-
Notifications
You must be signed in to change notification settings - Fork 170
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
Avoid drafts in chats where canSend is false #4394
Conversation
|
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.
I don't know if this is the right approach. The fact that useDraft
returns draftState
of the previous chat after you switch to a chat to which you cannot send, seems pretty wrong.
Maybe it would be simpler to just make the final return statement return dummy functions and objects instead. Hmmm, but then, the shortcut code is still active...
Or maybe just disable the shortcut and that's it, and wait for the composer refactor.
Also this doesn't actually disable the Ctrl + Up shortcut in !canSend
chats. The messages still get highlighted.
No changelog entry since bug was introduced in test release
I don't think so. You can utilize the Ctrl + Up shortcut in !canSend
chats in 1.48.0.
Also we'd probably want to merge #4395 first, because I think this MR makes it easier to crash when switching between chats.
206e641
to
07df8cf
Compare
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.
Ok, #4395 is merged and the shortcut no longer works where it shouldn't. Let's hope this can keep us afloat until the composer refactor!
In a readonly chat there should be no calls to setDraft or load draft at all. So if you prefer a minimal approach we could add the !canSend condition only to the shortcut in https://github.com/deltachat/deltachat-desktop/pull/4394/files#diff-ca83809f74f6819ef5c7d61676ac6c9abd27cb5becc46cb08bc9c43bc87c0f61R596 btw: it seems clearDraft is nowhere used outside of useDraft, so no need to return it. |
There was this MR #4342 which suggested making the draft editable even when But maybe I'm being too pedantic.
In this particular case yes, I'd prefer to be more conservative, but I won't insist. |
Returning null would mean to add non null checks in many places. I also don't like that loadDraft is called even in !canSend chats. Maybe it makes sense to add another clearDraft() call in loadDraft before returning.
I would say: these functions should never be called, but if called they should not add a draft to a readOnly chat |
Well yes, that's the point. You don't want to call a function that you expect to do something but that actually does nothing.
Yes, that's better than keeping the previous state of the draft. And |
resolves #4389