-
Notifications
You must be signed in to change notification settings - Fork 370
msglist: Make mark-as-read button listen to the Unreads model #2020
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1001,6 +1001,43 @@ void main() { | |
| check(isMarkAsReadButtonVisible(tester)).isFalse(); | ||
| }); | ||
|
|
||
| testWidgets('listens to Unreads model, not just PerAccountStore and MessageListView', (tester) async { | ||
| // Regression test for an edge case where the button wouldn't disappear | ||
| // when the narrow's unreads were cleared, because the button would only | ||
| // respond to notifications from PerAccountStore and MessageListView, | ||
| // not Unreads. To test this, we simulate an event that causes Unreads | ||
| // but not PerAccountStore and MessageListView to notify listeners, | ||
| // and check that the button responds. | ||
|
|
||
| final message = eg.streamMessage(flags: [MessageFlag.mentioned]); | ||
| final unreadMsgs = eg.unreadMsgs( | ||
| channels: [ | ||
| UnreadChannelSnapshot( | ||
| topic: message.topic, | ||
| streamId: message.streamId, | ||
| unreadMessageIds: [message.id], | ||
| ), | ||
| ], | ||
| mentions: [message.id], | ||
| ); | ||
| await setupMessageListPage(tester, | ||
| narrow: MentionsNarrow(), | ||
| unreadMsgs: unreadMsgs, | ||
| // omit `message`; if present, MessageListView would notify listeners | ||
| messages: List.generate(300, (i) => | ||
| eg.streamMessage(id: 950 + i, sender: eg.selfUser, | ||
| flags: [MessageFlag.read, MessageFlag.mentioned])), | ||
|
Comment on lines
+1026
to
+1029
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I see. IIUC, the point is that the message had been in the narrow, and an event removes it from the narrow; but it hadn't been one of the messages fetched, because it was too old. Is that right? I think that high-level strategy would be good to make explicit in the test's main comment above. It looks like the same thing would happen with a channel or topic narrow if the message got moved out of the channel/topic, too. |
||
| foundOldest: false); | ||
| check(isMarkAsReadButtonVisible(tester)).isTrue(); | ||
|
|
||
| // The message no longer has an @-mention. | ||
| // It was the only unread message with an @-mention, | ||
| // so the button should disappear. | ||
| await store.handleEvent(eg.updateMessageEditEvent(message, flags: [])); | ||
| await tester.pumpAndSettle(); | ||
| check(isMarkAsReadButtonVisible(tester)).isFalse(); | ||
| }); | ||
|
|
||
| testWidgets("messages don't shift position", (tester) async { | ||
| final message = eg.streamMessage(flags: []); | ||
| final unreadMsgs = eg.unreadMsgs(channels:[ | ||
|
|
||
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.
Since the premise of this test scenario is that this message is older than all the messages that get fetched, it'd be good to give it a smaller message ID too in order to be consistent with that.
That or leave all the message IDs out — they're really only needed when the messages get constructed in the test out of order from when they were supposed to be sent.