@@ -278,6 +278,15 @@ const markAsUnreadFromMessage = {
278
278
} ,
279
279
} ;
280
280
281
+ const unmuteTopicInMutedStream = {
282
+ title : 'Unmute topic' ,
283
+ errorMessage : 'Failed to unmute topic' ,
284
+ action : async ( { auth, streamId, topic, streams, zulipFeatureLevel } ) => {
285
+ invariant ( zulipFeatureLevel >= 170 , 'Should only attempt to unmute in muted stream on FL 170+' ) ;
286
+ await api . updateUserTopic ( auth , streamId , topic , UserTopicVisibilityPolicy . Unmuted ) ;
287
+ } ,
288
+ } ;
289
+
281
290
const unmuteTopic = {
282
291
title : 'Unmute topic' ,
283
292
errorMessage : 'Failed to unmute topic' ,
@@ -631,13 +640,14 @@ export const constructTopicActionButtons = (args: {|
631
640
ownUserRole : Role ,
632
641
subscriptions : Map < number , Subscription> ,
633
642
unread : UnreadState ,
643
+ zulipFeatureLevel : number ,
634
644
...
635
645
} > ,
636
646
streamId : number ,
637
647
topic : string ,
638
648
| } ) : Button < TopicArgs > [ ] = > {
639
649
const { backgroundData, streamId, topic } = args ;
640
- const { mute, ownUserRole, subscriptions, unread } = backgroundData ;
650
+ const { mute, ownUserRole, subscriptions, unread, zulipFeatureLevel } = backgroundData ;
641
651
const sub = subscriptions . get ( streamId ) ;
642
652
const streamMuted = ! ! sub && ! sub . in_home_view ;
643
653
@@ -658,7 +668,19 @@ export const constructTopicActionButtons = (args: {|
658
668
break ;
659
669
}
660
670
} else if ( sub && streamMuted ) {
661
- // TODO(#5691): offer new "unmute topic" concept, when server supports it
671
+ // Muted stream.
672
+ // TODO(server-7.0): Simplify this condition away.
673
+ if ( zulipFeatureLevel >= 170 ) {
674
+ switch ( getTopicVisibilityPolicy ( mute , streamId , topic ) ) {
675
+ case UserTopicVisibilityPolicy . None :
676
+ case UserTopicVisibilityPolicy . Muted :
677
+ buttons . push ( unmuteTopicInMutedStream ) ;
678
+ break ;
679
+ case UserTopicVisibilityPolicy . Unmuted :
680
+ buttons . push ( muteTopic ) ;
681
+ break ;
682
+ }
683
+ }
662
684
} else {
663
685
// Not subscribed to stream at all; no muting.
664
686
}
0 commit comments