Skip to content

Conversation

@chrisbobbe
Copy link
Collaborator

This PR gets us much closer to #1798, i.e. handling that we don't expect events about messages in unsubscribed channels. 🙂

When the "first" and "third" are fixed (as here), we can finish the rest of the "second" (reasoning is explained in #1873). 🙂

Fixes-partly: #1798

This fixes half of the "first buggy behavior" described in zulip#1798,
specifically the send-message case. We'll fix it for the
edit-message case too, coming up.

Fixes-partly: zulip#1798
This fixes half of the "third buggy behavior" described in zulip#1798:
the send-message case. We'll fix it for the edit-message case too,
coming up.

Fixes-partly: zulip#1798
This fixes the rest of the "first buggy behavior" described
in zulip#1798: it fixes it for the edit-message case.

Fixes-partly: zulip#1798
This fixes the rest of the "third buggy behavior" described
in zulip#1798: it fixes it for the edit-message case.

Fixes-partly: zulip#1798
@chrisbobbe chrisbobbe added the maintainer review PR ready for review by Zulip maintainers label Dec 12, 2025
Copy link
Member

@rajveermalviya rajveermalviya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @chrisbobbe! LGTM, and tests great! Moving over to Greg's review.

@rajveermalviya rajveermalviya added integration review Added by maintainers when PR may be ready for integration and removed maintainer review PR ready for review by Zulip maintainers labels Dec 12, 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. Comments below on the first two commits:
7d73858 msglist: In unsubscribed channel, refresh on message-send success
2e82af2 msglist: In unsubscribed channel, clear outbox message on send success

It looks like the remaining two are fairly parallel to those:
522df03 msglist: In unsubscribed channel, refresh on message-edit success
2be8ead msglist: In unsubscribed channel, clear edit progress on request success

so I'll read them in more detail after we're settled on specifics of the first two.

}

final store = PerAccountStoreWidget.of(context);
PerAccountStore store = PerAccountStoreWidget.of(context);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see, the point is we'll mutate this variable after the async gap, looking up the new value it should have.

nit: Let's move this line to just before the one place this version is used. (And it can go back to final.) That way it's clearer that this should only be used before the async gap, and harder to accidentally use it after.

}

store = PerAccountStoreWidget.of(context);
final destination = widget.getDestination();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point is this is the destination we just sent to, right? Perhaps save that earlier in a variable, vs. recomputing here, to make that clearer.

Comment on lines +1353 to +1355
) {
// We don't get new-message events for unsubscribed channels,
// but we can refresh the view when a send-message request succeeds,
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 this could use a line setting the context a bit more broadly:

Suggested change
) {
// We don't get new-message events for unsubscribed channels,
// but we can refresh the view when a send-message request succeeds,
) {
// The message was sent to an unsubscribed channel.
// We don't get new-message events for unsubscribed channels,
// but we can refresh the view when a send-message request succeeds,

Comment on lines +902 to +905
/// Event received, or [sendMessage]
/// request succeeds and we're sending to
/// an unsubscribed channel.
/// (any state) ───────────────────────────────────────► (delete)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: In general with these changes, I worry somewhat about making it harder to understand the main case. This can help a bit here:

Suggested change
/// Event received, or [sendMessage]
/// request succeeds and we're sending to
/// an unsubscribed channel.
/// (any state) ───────────────────────────────────────► (delete)
/// Event received. Or [sendMessage]
/// request succeeds and we're sending to
/// an unsubscribed channel.
/// (any state) ───────────────────────────────────────► (delete)

In particular that makes it clear up front that "event received" is a complete description of one way this transition can happen, and there aren't further caveats about it coming later.

Comment on lines +1167 to +1170
if (destination is StreamDestination && subscriptions[destination.streamId] == null) {
// We don't expect an event (we're sending to an unsubscribed channel);
// clear the loading spinner.
_outboxMessages.remove(localMessageId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. This means we'll remove not only the loading spinner, but also the local-echo version of the message itself, right? That seems potentially unhelpful.

Though I guess this might be simultaneous with reloading the affected message lists from scratch? In that case the user wouldn't see a state where the message appears to have vanished.

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.

3 participants