mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
refactor: Extract time calculation logic for topic muting.
This is a prep change for implementing the mute users feature, so that this code can be reused.
This commit is contained in:
committed by
Tim Abbott
parent
f4c3ad5818
commit
95663693df
@@ -6,18 +6,20 @@ import * as timerender from "./timerender";
|
||||
|
||||
const muted_topics = new Map();
|
||||
|
||||
function get_time_from_date_muted(date_muted) {
|
||||
if (date_muted === undefined) {
|
||||
return Date.now();
|
||||
}
|
||||
return date_muted * 1000;
|
||||
}
|
||||
|
||||
export function add_muted_topic(stream_id, topic, date_muted) {
|
||||
let sub_dict = muted_topics.get(stream_id);
|
||||
if (!sub_dict) {
|
||||
sub_dict = new FoldDict();
|
||||
muted_topics.set(stream_id, sub_dict);
|
||||
}
|
||||
let time;
|
||||
if (date_muted === undefined) {
|
||||
time = Date.now();
|
||||
} else {
|
||||
time = date_muted * 1000;
|
||||
}
|
||||
const time = get_time_from_date_muted(date_muted);
|
||||
sub_dict.set(topic, time);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user