Skip to content

Commit 2f7f021

Browse files
committed
unreads: Take a missed opportunity for a debugLog to fire when helpful
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.
1 parent 33fb619 commit 2f7f021

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/model/unreads.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,14 @@ class Unreads extends ChangeNotifier {
265265
// https://chat.zulip.org/#narrow/stream/378-api-design/topic/mark-as-read.20events.20with.20message.20moves.3F/near/1639957
266266
final bool isRead = event.flags.contains(MessageFlag.read);
267267
assert(() {
268-
final isUnreadLocally = _slowIsPresentInDms(messageId) || _slowIsPresentInStreams(messageId);
268+
final isUnreadLocally = isUnread(messageId);
269269
final isUnreadInEvent = !isRead;
270-
if (!oldUnreadsMissing && isUnreadLocally != isUnreadInEvent) {
270+
271+
// Unread state unknown because of [oldUnreadsMissing].
272+
// We were going to check something but can't; shrug.
273+
if (isUnreadLocally == null) return true;
274+
275+
if (isUnreadLocally != isUnreadInEvent) {
271276
// If this happens, then either:
272277
// - the server and client have been out of sync about the message's
273278
// unread state since before this event, or

0 commit comments

Comments
 (0)