-
Notifications
You must be signed in to change notification settings - Fork 370
model: Prevent duplicate flags when processing update_message_flags. #2033
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 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1702,6 +1702,34 @@ void main() { | |||||||||
| check(store).messages.values | ||||||||||
| .single.flags.deepEquals([MessageFlag.starred, MessageFlag.read]); | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| test('avoid duplicate flags', () async { | ||||||||||
| // Regression test for https://github.com/zulip/zulip-flutter/issues/1986 | ||||||||||
| await prepare(); | ||||||||||
| final message = eg.streamMessage(flags: [MessageFlag.read]); | ||||||||||
| await prepareMessages([message]); | ||||||||||
|
|
||||||||||
| await store.handleEvent(mkAddEvent(MessageFlag.read, [message.id])); | ||||||||||
| check(store).messages.values.single.flags.deepEquals([MessageFlag.read]); | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| test('handle update_message_flags: add flag "all" is idempotent', () async { | ||||||||||
|
Collaborator
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. I'd like to give the two new tests more similar descriptions, so it's more obvious that they're testing very similar logic. How about:
or similar. |
||||||||||
| // Regression test for https://github.com/zulip/zulip-flutter/issues/1986 | ||||||||||
| await prepare(); | ||||||||||
| final m1 = eg.streamMessage(flags: [MessageFlag.read]); | ||||||||||
| final m2 = eg.streamMessage(flags: []); | ||||||||||
|
Comment on lines
+1719
to
+1720
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. nit:
Suggested change
This point about avoiding abbreviations, in the Flutter upstream style guide, applies equally in Zulip: (And not only in the mobile repo — in fact I think Tim applies it more strongly than I do, and we've been doing so since long before we used Flutter.) |
||||||||||
| await prepareMessages([m1, m2]); | ||||||||||
|
|
||||||||||
| await store.handleEvent(UpdateMessageFlagsAddEvent( | ||||||||||
| id: 1, | ||||||||||
|
Comment on lines
+1723
to
+1724
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. nit: like the other cases in this group, use |
||||||||||
| all: true, | ||||||||||
| flag: MessageFlag.read, | ||||||||||
| messages: [], | ||||||||||
| )); | ||||||||||
|
|
||||||||||
| check(store.messages[m1.id]!.flags).deepEquals([MessageFlag.read]); | ||||||||||
| check(store.messages[m2.id]!.flags).deepEquals([MessageFlag.read]); | ||||||||||
|
Comment on lines
+1730
to
+1731
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. nit: Conversely, for making this a bit more compact again, see the test cases with "message1" and "message2" earlier in this group. Those give examples of how the |
||||||||||
| }); | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| group('remove flag', () { | ||||||||||
|
|
||||||||||
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.
Please also write a test exercising this case.