Skip to content

Commit 6a97764

Browse files
committed
mute: Show all topics as muted in a muted stream's topic list
Just like we do on web. This will also set us up to show the distinction when some topics are *un*muted soon.
1 parent ec1ba3c commit 6a97764

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/topics/topicSelectors.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { getUnread, getUnreadCountForTopic } from '../unread/unreadModel';
77
import { NULL_ARRAY } from '../nullObjects';
88
import { isStreamNarrow, streamIdOfNarrow } from '../utils/narrow';
99
import { getMute, isTopicMuted } from '../mute/muteModel';
10+
import { getSubscriptionsById } from '../subscriptions/subscriptionSelectors';
1011

1112
export const getTopicsForNarrow: Selector<$ReadOnlyArray<string>, Narrow> = createSelector(
1213
(state, narrow) => narrow,
@@ -27,15 +28,21 @@ export const getTopicsForNarrow: Selector<$ReadOnlyArray<string>, Narrow> = crea
2728
export const getTopicsForStream: Selector<?$ReadOnlyArray<TopicExtended>, number> = createSelector(
2829
(state, streamId) => streamId,
2930
(state, streamId) => getTopics(state)[streamId],
31+
(state, streamId) => getSubscriptionsById(state).get(streamId),
3032
state => getMute(state),
3133
state => getUnread(state),
32-
(streamId, topicList, mute, unread) => {
34+
(streamId, topicList, subscription, mute, unread) => {
3335
if (!topicList) {
3436
return undefined;
3537
}
3638

37-
return topicList.map(({ name, max_id }) => {
38-
const isMuted = isTopicMuted(streamId, name, mute);
39+
// If we're looking at a stream the user isn't subscribed to, then
40+
// they won't see unreads from it even if they somehow have
41+
// individual topics set to unmuted. So effectively it's all muted.
42+
const streamMuted = subscription ? !subscription.in_home_view : true;
43+
44+
return topicList.map(({ name, max_id }): TopicExtended => {
45+
const isMuted = streamMuted || isTopicMuted(streamId, name, mute);
3946
const unreadCount = getUnreadCountForTopic(unread, streamId, name);
4047
return { name, max_id, isMuted, unreadCount };
4148
});

0 commit comments

Comments
 (0)