@@ -21,6 +21,7 @@ import type {
21
21
Stream ,
22
22
LocalizableText ,
23
23
} from '../types' ;
24
+ import { UserTopicVisibilityPolicy } from '../api/modelTypes' ;
24
25
import type { UnreadState } from '../unread/unreadModelTypes' ;
25
26
import {
26
27
apiNarrowOfNarrow ,
@@ -280,22 +281,32 @@ const markAsUnreadFromMessage = {
280
281
const unmuteTopic = {
281
282
title : 'Unmute topic' ,
282
283
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
+ }
288
294
} ,
289
295
} ;
290
296
291
297
const muteTopic = {
292
298
title : 'Mute topic' ,
293
299
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
+ }
299
310
} ,
300
311
} ;
301
312
0 commit comments