Skip to content

Commit 9380ac7

Browse files
committed
msglist: In "Starred messages", show DMs even if all recipients muted
See reasoning in added dartdoc and implementation comments in _messageVisible.
1 parent a9b8929 commit 9380ac7

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

lib/model/message_list.dart

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,10 @@ class MessageListView with ChangeNotifier, _MessageSequence {
668668
/// This depends in particular on whether the message is muted in
669669
/// one way or another.
670670
///
671-
/// See also [_allMessagesVisible].
671+
/// See also:
672+
/// - [_allMessagesVisible], message-fetch optimization related to this
673+
/// - Message-list UI that mitigates spam/harrassment
674+
/// by obscuring messages from muted senders, with a "reveal" button
672675
bool _messageVisible(MessageBase message) {
673676
switch (narrow) {
674677
case CombinedFeedNarrow():
@@ -694,7 +697,23 @@ class MessageListView with ChangeNotifier, _MessageSequence {
694697
// If changing this, consider whether [Unreads.countInMentionsNarrow]
695698
// should be changed correspondingly, so the message-list view matches
696699
// the unread-count badge.
700+
if (message.conversation case DmConversation(:final allRecipientIds)) {
701+
return !store.shouldMuteDmConversation(DmNarrow(
702+
allRecipientIds: allRecipientIds, selfUserId: store.selfUserId));
703+
}
704+
return true;
705+
697706
case StarredMessagesNarrow():
707+
// Include messages even if muted in some way.
708+
// Other users can't spam the starred-messages view by starring;
709+
// the starred state is read/write by the self-user only.
710+
//
711+
// If we want to change this, consider that we need to compute a
712+
// starred-message count without relying on fetched message data:
713+
// https://zulip.com/help/star-a-message#view-your-starred-messages
714+
// ([MessageStore.starredMessages] is just a list of message IDs.)
715+
return true;
716+
698717
case KeywordSearchNarrow():
699718
if (message.conversation case DmConversation(:final allRecipientIds)) {
700719
return !store.shouldMuteDmConversation(DmNarrow(
@@ -718,7 +737,11 @@ class MessageListView with ChangeNotifier, _MessageSequence {
718737
return true;
719738

720739
case MentionsNarrow():
740+
return false;
741+
721742
case StarredMessagesNarrow():
743+
return true;
744+
722745
case KeywordSearchNarrow():
723746
return false;
724747
}
@@ -757,7 +780,11 @@ class MessageListView with ChangeNotifier, _MessageSequence {
757780
return MutedUsersVisibilityEffect.none;
758781

759782
case MentionsNarrow():
783+
return store.mightChangeShouldMuteDmConversation(event);
784+
760785
case StarredMessagesNarrow():
786+
return MutedUsersVisibilityEffect.none;
787+
761788
case KeywordSearchNarrow():
762789
return store.mightChangeShouldMuteDmConversation(event);
763790
}

test/model/message_list_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,8 +1253,8 @@ void main() {
12531253
checkHasMessageIds([1, 2, 3]);
12541254

12551255
await store.setMutedUsers([user1.userId]);
1256-
checkNotifiedOnce();
1257-
checkHasMessageIds([2, 3]);
1256+
checkNotNotified();
1257+
checkHasMessageIds([1, 2, 3]);
12581258
});
12591259

12601260
test('ChannelNarrow -> do nothing', () async {
@@ -3261,12 +3261,12 @@ void checkInvariants(MessageListView model) {
32613261
switch (model.narrow) {
32623262
case CombinedFeedNarrow():
32633263
case MentionsNarrow():
3264-
case StarredMessagesNarrow():
32653264
case KeywordSearchNarrow():
32663265
check(model.store.shouldMuteDmConversation(narrow)).isFalse();
32673266
case ChannelNarrow():
32683267
case TopicNarrow():
32693268
case DmNarrow():
3269+
case StarredMessagesNarrow():
32703270
}
32713271
}
32723272
}

0 commit comments

Comments
 (0)