Skip to content

Commit 75c533c

Browse files
committed
api types: Add UserTopic type, preparing for user_topic API
This just adds type definitions, without changing the types we expect from the server. After this, as the next steps: * we'll migrate the data structure we maintain in our own store to one that can smoothly handle the new API format; * then as a separate step after that, we'll switch to actually consuming the new API format. It's convenient to use this UserTopicVisibilityPolicy type in describing that new data structure's type. Hence we add it early, in this commit, before we actually start requesting the new format (or update our event and initial-data types to reflect doing so).
1 parent f8f698f commit 75c533c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/api/modelTypes.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,29 @@ export type Topic = $ReadOnly<{|
635635
max_id: number,
636636
|}>;
637637

638+
/**
639+
* A user's policy for whether and how to see a particular topic.
640+
*
641+
* See `visibility_policy` at: https://zulip.com/api/get-events#user_topic
642+
*/
643+
export enum UserTopicVisibilityPolicy {
644+
None = 0,
645+
Muted = 1,
646+
}
647+
648+
/**
649+
* A user's relationship to a topic; in particular, muting.
650+
*
651+
* Found in the initial data at `user_topics`, and in `user_topic` events:
652+
* https://zulip.com/api/get-events#user_topic
653+
*/
654+
export type UserTopic = {|
655+
+stream_id: number,
656+
+topic_name: string,
657+
+last_updated: number,
658+
+visibility_policy: UserTopicVisibilityPolicy,
659+
|};
660+
638661
/**
639662
* A muted topic.
640663
*
@@ -645,6 +668,7 @@ export type Topic = $ReadOnly<{|
645668
// Server issue for using stream IDs (#3918) for muted topics, not names:
646669
// https://github.com/zulip/zulip/issues/21015
647670
// TODO(server-3.0): Simplify away the no-timestamp version, new in FL 1.
671+
// TODO(server-6.0): Remove, in favor of UserTopic.
648672
export type MutedTopicTuple = [string, string] | [string, string, number];
649673

650674
//

0 commit comments

Comments
 (0)