-
Notifications
You must be signed in to change notification settings - Fork 321
edit-message: Show error dialog on edit-message request error #1792
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
base: main
Are you sure you want to change the base?
Conversation
I'm fairly certain this is NFC. The two calls do operate on shared state, in the controller, but it should suffice to just capture `messageId` and `newContent` from the ComposeBoxController before endMessageEdit disposes it. Soon we'd like `store.editMessage` to return a Future, which we'd like to await and add some error feedback, just like we have in the send-message UX.
See added dartdoc for motivation. I don't think there's a behavior change here; we don't use the passed BuildContext after an async gap. We'd like to do that soon, though: to show an error dialog on API errors from the edit-message request; such errors will arrive after the banner has disappeared.
I'm not finding the discussion where we said we wanted this (for consistency with the send-message UX), but I think we did. Error-feedback logic copied from the tap-"Send" button (_SendButtonState._send) modulo the error dialog's title, "Message not saved" vs. "Message not sent".
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.
Thanks! Generally this all looks good; a couple of comments below.
final messageId = controller.messageId; | ||
final newContent = controller.content.textNormalized; | ||
composeBoxState.endEditInteraction(); |
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.
compose_box: Reorder two calls in edit-message "Save" tap handler
I'm fairly certain this is NFC. The two calls do operate on shared
state, in the controller, but it should suffice to just capture
`messageId` and `newContent` from the ComposeBoxController before
endMessageEdit disposes it.
I don't quite follow this part — which two calls operate on shared state in the controller? I don't think store.editMessage
operates on the controller; it's down in the model layer and shouldn't know about UI state like a compose-box controller anyway.
/// The returned [Future] resolves or rejects with the edit-message request, | ||
/// irrespective of when the edit-message event arrives (if it does). |
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 think the actual behavior is good, but this description doesn't quite capture it:
- If the request fails, but only after the event has already arrived, the future resolves rather than rejects.
- Similarly if the request fails but the message has been deleted.
- As of this commit, the future actually never rejects (short of a bug, like reaching the
throw StateError
line); that only happens when therethrow
is added in a later commit. Probably that rethrow can just be part of this commit.
With #188, the message-list UI for an unsubscribed channel will become more prominent, which calls for fixing at least the following glitch:
Since we don't get events when the self-user sends or edits a message in an unsubscribed channel, we'd like to refetch messages on success of those actions. Discussion: #mobile > Message sending in unsubscribed channels @ 💬 So, on the path to that, make
store.editMessage
similar tostore.sendMessage
in returningFuture<void>
instead ofvoid
, where the returned Future resolves or rejects with the API request, irrespective of the event.While we're at it, show an error dialog when the edit fails, as we've been meaning to do, again for consistency with the send-message UX.
Compare error feedback on sending an invalid message (in
main
and unchanged here) vs. trying to save an invalid message edit (new here; inmain
we show no dialog):The outbox logic is unchanged. As in
main
, we show "MESSAGE NOT SENT" and "EDIT NOT SAVED" in the message list, and these are tappable to restore the composing session and try again.