@@ -7,6 +7,7 @@ import { getUnread, getUnreadCountForTopic } from '../unread/unreadModel';
7
7
import { NULL_ARRAY } from '../nullObjects' ;
8
8
import { isStreamNarrow , streamIdOfNarrow } from '../utils/narrow' ;
9
9
import { getMute , isTopicMuted } from '../mute/muteModel' ;
10
+ import { getSubscriptionsById } from '../subscriptions/subscriptionSelectors' ;
10
11
11
12
export const getTopicsForNarrow : Selector < $ReadOnlyArray < string > , Narrow > = createSelector (
12
13
( state , narrow ) => narrow ,
@@ -27,15 +28,21 @@ export const getTopicsForNarrow: Selector<$ReadOnlyArray<string>, Narrow> = crea
27
28
export const getTopicsForStream : Selector < ?$ReadOnlyArray < TopicExtended > , number > = createSelector (
28
29
( state , streamId ) => streamId ,
29
30
( state , streamId ) => getTopics ( state ) [ streamId ] ,
31
+ ( state , streamId ) => getSubscriptionsById ( state ) . get ( streamId ) ,
30
32
state => getMute ( state ) ,
31
33
state => getUnread ( state ) ,
32
- ( streamId , topicList , mute , unread ) => {
34
+ ( streamId , topicList , subscription , mute , unread ) => {
33
35
if ( ! topicList ) {
34
36
return undefined ;
35
37
}
36
38
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 ) ;
39
46
const unreadCount = getUnreadCountForTopic ( unread , streamId , name ) ;
40
47
return { name, max_id, isMuted, unreadCount } ;
41
48
} ) ;
0 commit comments