Skip to content

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

chrisbobbe
Copy link
Collaborator

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 to store.sendMessage in returning Future<void> instead of void, 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; in main we show no dialog):

Send Edit
image image

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.

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".
@chrisbobbe chrisbobbe requested a review from gnprice August 6, 2025 04:08
@chrisbobbe chrisbobbe added the integration review Added by maintainers when PR may be ready for integration label Aug 6, 2025
Copy link
Member

@gnprice gnprice left a 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.

Comment on lines +1800 to 1802
final messageId = controller.messageId;
final newContent = controller.content.textNormalized;
composeBoxState.endEditInteraction();
Copy link
Member

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.

Comment on lines +61 to +62
/// The returned [Future] resolves or rejects with the edit-message request,
/// irrespective of when the edit-message event arrives (if it does).
Copy link
Member

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 the rethrow is added in a later commit. Probably that rethrow can just be part of this commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration review Added by maintainers when PR may be ready for integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants