-
Notifications
You must be signed in to change notification settings - Fork 237
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
unreads: Fix false positives in a debug check; log in another case when helpful #1150
Conversation
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.
Looks good! Left a comment.
test/model/unreads_test.dart
Outdated
}); | ||
} | ||
|
||
doTestCommon('unread DM message', unreadDmMessage.id, true); |
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.
nit: Should we make the third parameter use a keyword? Just by looking at it it is not so obvious what this is supposed to mean.
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.
Sure; made this a named param.
We don't expect UpdateMessageEvent to signal a change in a message's read state; that's what UpdateMessageFlagsEvent is for. Our unreads model does process `UpdateMessageEvent`s, though, to apply changes in a message's mentioned state. Also, we expect the client to be synced with the server for all messages' read state, assuming !oldUnreadsMissing. Where we process `UpdateMessageEvent`s, we have a `debugLog` line to alert us if one of these expectations isn't being met. It's been giving false positives when we get an UpdateMessageEvent for a bulk message move where some of the moved messages are read and some aren't. Since the server only intends the event's `flags` to apply to the event's `messageId` (one message), we should only be checking that message, not all the messages in the event's `messageIds`. From the API doc on `flags`: https://zulip.com/api/get-events#update_message > The user's personal message flags for the message with ID > message_id following the edit.
And make it public, with dartdoc and tests, while we're at it.
For this debug check to work, it just needs a known read state for one message. When `oldUnreadsMissing` is false (the common case), the model holds one of two answers for a message's read state: known-unread or known-read. When `oldUnreadsMissing` is true, the model holds known-unread or unknown. Before, we were skipping the debug check on seeing that `oldUnreadsMissing` is true. That's earlier than we need to abort, because the model might still hold a known-unread state for the message. Now, we go ahead with the debug check if that's the case, and still skip it otherwise. Done by using our new `isUnread` helper, in this separate commit because it's not NFC in debug mode.
2f7f021
to
7d64e2f
Compare
Thanks for the review! Revision pushed. Since you had just one nit, which I've fixed, I'll go ahead and mark for Greg's review. |
Thanks! Looks good; merging. |
In manual testing for my work on resolve/unresolve #744, I noticed some surprising debug-log lines that turned out to be false positives, so this fixes those.
It also makes the debug check run in a helpful case where it wasn't running before.