mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 00:46:03 +00:00
user_topics: Add set_user_topic helper function.
As we plan to move towards using `user_topics` instead of `muted_topics`, this helper method will be used to set an individual `user_topic` event in the corresponding data structure in the web app.
This commit is contained in:
committed by
Tim Abbott
parent
6cdf2853ff
commit
cf4bbf1ba5
@@ -7,6 +7,13 @@ import {get_time_from_date_muted} from "./util";
|
||||
|
||||
const muted_topics = new Map();
|
||||
|
||||
export const visibility_policy = {
|
||||
VISIBILITY_POLICY_INHERIT: 0,
|
||||
MUTED: 1,
|
||||
UNMUTED: 2,
|
||||
FOLLOWED: 3,
|
||||
};
|
||||
|
||||
export function add_muted_topic(stream_id, topic, date_muted) {
|
||||
let sub_dict = muted_topics.get(stream_id);
|
||||
if (!sub_dict) {
|
||||
@@ -51,6 +58,28 @@ export function get_muted_topics() {
|
||||
return topics;
|
||||
}
|
||||
|
||||
export function set_user_topic(user_topic) {
|
||||
const stream_id = user_topic.stream_id;
|
||||
const topic = user_topic.topic_name;
|
||||
const date_muted = user_topic.last_updated;
|
||||
|
||||
const stream_name = stream_data.maybe_get_stream_name(stream_id);
|
||||
|
||||
if (!stream_name) {
|
||||
blueslip.warn("Unknown stream ID in set_user_topic: " + stream_id);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (user_topic.visibility_policy) {
|
||||
case visibility_policy.MUTED:
|
||||
add_muted_topic(stream_id, topic, date_muted);
|
||||
break;
|
||||
case visibility_policy.VISIBILITY_POLICY_INHERIT:
|
||||
remove_muted_topic(stream_id, topic);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
export function set_muted_topics(tuples) {
|
||||
muted_topics.clear();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user