@@ -21,6 +21,7 @@ import type {
2121 Stream ,
2222 LocalizableText ,
2323} from '../types' ;
24+ import { UserTopicVisibilityPolicy } from '../api/modelTypes' ;
2425import type { UnreadState } from '../unread/unreadModelTypes' ;
2526import {
2627 apiNarrowOfNarrow ,
@@ -280,22 +281,32 @@ const markAsUnreadFromMessage = {
280281const unmuteTopic = {
281282 title : 'Unmute topic' ,
282283 errorMessage : 'Failed to unmute topic' ,
283- action : async ( { auth, streamId, topic, streams } ) => {
284- const stream = streams . get ( streamId ) ;
285- invariant ( stream !== undefined , 'Stream with provided streamId must exist.' ) ;
286- // This still uses a stream name (#3918) because the API method does; see there.
287- await api . setTopicMute ( auth , stream . name , topic , false ) ;
284+ action : async ( { auth, streamId, topic, streams, zulipFeatureLevel } ) => {
285+ if ( zulipFeatureLevel >= 170 ) {
286+ await api . updateUserTopic ( auth , streamId , topic , UserTopicVisibilityPolicy . None ) ;
287+ } else {
288+ // TODO(server-7.0): Cut this fallback to setTopicMute.
289+ const stream = streams . get ( streamId ) ;
290+ invariant ( stream !== undefined , 'Stream with provided streamId must exist.' ) ;
291+ // This still uses a stream name (#3918) because the API method does; see there.
292+ await api . setTopicMute ( auth , stream . name , topic , false ) ;
293+ }
288294 } ,
289295} ;
290296
291297const muteTopic = {
292298 title : 'Mute topic' ,
293299 errorMessage : 'Failed to mute topic' ,
294- action : async ( { auth, streamId, topic, streams } ) => {
295- const stream = streams . get ( streamId ) ;
296- invariant ( stream !== undefined , 'Stream with provided streamId must exist.' ) ;
297- // This still uses a stream name (#3918) because the API method does; see there.
298- await api . setTopicMute ( auth , stream . name , topic , true ) ;
300+ action : async ( { auth, streamId, topic, streams, zulipFeatureLevel } ) => {
301+ if ( zulipFeatureLevel >= 170 ) {
302+ await api . updateUserTopic ( auth , streamId , topic , UserTopicVisibilityPolicy . Muted ) ;
303+ } else {
304+ // TODO(server-7.0): Cut this fallback to setTopicMute.
305+ const stream = streams . get ( streamId ) ;
306+ invariant ( stream !== undefined , 'Stream with provided streamId must exist.' ) ;
307+ // This still uses a stream name (#3918) because the API method does; see there.
308+ await api . setTopicMute ( auth , stream . name , topic , true ) ;
309+ }
299310 } ,
300311} ;
301312
0 commit comments