@@ -278,6 +278,15 @@ const markAsUnreadFromMessage = {
278278 } ,
279279} ;
280280
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+
281290const unmuteTopic = {
282291 title : 'Unmute topic' ,
283292 errorMessage : 'Failed to unmute topic' ,
@@ -631,13 +640,14 @@ export const constructTopicActionButtons = (args: {|
631640 ownUserRole : Role ,
632641 subscriptions : Map < number , Subscription> ,
633642 unread : UnreadState ,
643+ zulipFeatureLevel : number ,
634644 ...
635645 } > ,
636646 streamId : number ,
637647 topic : string ,
638648| } ) : Button < TopicArgs > [ ] = > {
639649 const { backgroundData, streamId, topic } = args ;
640- const { mute, ownUserRole, subscriptions, unread } = backgroundData ;
650+ const { mute, ownUserRole, subscriptions, unread, zulipFeatureLevel } = backgroundData ;
641651 const sub = subscriptions . get ( streamId ) ;
642652 const streamMuted = ! ! sub && ! sub . in_home_view ;
643653
@@ -658,7 +668,19 @@ export const constructTopicActionButtons = (args: {|
658668 break ;
659669 }
660670 } 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+ }
662684 } else {
663685 // Not subscribed to stream at all; no muting.
664686 }
0 commit comments