Skip to content

Commit 4bc5d61

Browse files
committed
narrow [nfc]: Inline showStreamInHomeNarrow
For an upcoming change to this logic, we'll want the call site to have its hands on the Subscription object.
1 parent 1c1ab3e commit 4bc5d61

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

src/chat/narrowsSelectors.js

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -87,22 +87,6 @@ export const getMessagesForNarrow: Selector<$ReadOnlyArray<Message | Outbox>, Na
8787
},
8888
);
8989

90-
/** Whether this stream's messages should appear in the "all messages" narrow. */
91-
const showStreamInHomeNarrow = (
92-
streamId: number,
93-
subscriptions: Map<number, Subscription>,
94-
): boolean => {
95-
const sub = subscriptions.get(streamId);
96-
if (!sub) {
97-
// If there's no matching subscription, then the user must have
98-
// unsubscribed from the stream since the message was received. Leave
99-
// those messages out of this view, just like for a muted stream.
100-
return false;
101-
}
102-
103-
return sub.in_home_view;
104-
};
105-
10690
/**
10791
* The known messages that should appear in the given narrow's message list.
10892
*
@@ -128,8 +112,15 @@ export const getShownMessagesForNarrow: Selector<$ReadOnlyArray<Message | Outbox
128112
if (flags.mentioned[message.id]) {
129113
return true;
130114
}
115+
const sub = subscriptions.get(message.stream_id);
116+
if (!sub) {
117+
// If there's no matching subscription, then the user must have
118+
// unsubscribed from the stream since the message was received. Leave
119+
// those messages out of this view, just like for a muted stream.
120+
return false;
121+
}
131122
return (
132-
showStreamInHomeNarrow(message.stream_id, subscriptions)
123+
sub.in_home_view
133124
&& !isTopicMuted(message.stream_id, message.subject, mute)
134125
);
135126
}),

0 commit comments

Comments
 (0)