Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
inbox_ui: Extract FILTERS to views_util.
Aman Agrawal2c76ef9a730f
diff --git a/web/src/inbox_ui.js b/web/src/inbox_ui.jsindex fcc83dec344..8eb7413b217 100644--- a/web/src/inbox_ui.js+++ b/web/src/inbox_ui.js@@ -38,12 +38,6 @@ let streams_dict = new Map();let update_triggered_by_user = false;let filters_dropdown_widget;-const FILTERS = {- ALL_TOPICS: "all_topics",- UNMUTED_TOPICS: "unmuted_topics",- FOLLOWED_TOPICS: "followed_topics",-};-const COLUMNS = {COLLAPSE_BUTTON: 0,RECIPIENT: 1,@@ -58,7 +52,7 @@ const ls_filter_key = "inbox-filters";const ls_collapsed_containers_key = "inbox_collapsed_containers";const ls = localstorage();-let filters = new Set([FILTERS.UNMUTED_TOPICS]);+let filters = new Set([views_util.FILTERS.UNMUTED_TOPICS]);let collapsed_containers = new Set();let search_keyword = "";@@ -133,11 +127,11 @@ function get_stream_header_row(stream_id) {function load_data_from_ls() {const saved_filters = new Set(ls.get(ls_filter_key));- const valid_filters = new Set(Object.values(FILTERS));+ const valid_filters = new Set(Object.values(views_util.FILTERS));// If saved filters are not in the list of valid filters, we reset to default.const is_subset = [...saved_filters].every((filter) => valid_filters.has(filter));if (saved_filters.size === 0 || !is_subset) {- filters = new Set([FILTERS.UNMUTED_TOPICS]);+ filters = new Set([views_util.FILTERS.UNMUTED_TOPICS]);} else {filters = saved_filters;}@@ -506,25 +500,25 @@ function show_empty_inbox_text(has_visible_unreads) {function filters_dropdown_options() {return [{- unique_id: FILTERS.ALL_TOPICS,+ unique_id: views_util.FILTERS.ALL_TOPICS,name: $t({defaultMessage: "All topics"}),bold_current_selection:filters_dropdown_widget &&- filters_dropdown_widget.current_value === FILTERS.ALL_TOPICS,+ filters_dropdown_widget.current_value === views_util.FILTERS.ALL_TOPICS,},{- unique_id: FILTERS.UNMUTED_TOPICS,+ unique_id: views_util.FILTERS.UNMUTED_TOPICS,name: $t({defaultMessage: "Unmuted topics"}),bold_current_selection:filters_dropdown_widget &&- filters_dropdown_widget.current_value === FILTERS.UNMUTED_TOPICS,+ filters_dropdown_widget.current_value === views_util.FILTERS.UNMUTED_TOPICS,},{- unique_id: FILTERS.FOLLOWED_TOPICS,+ unique_id: views_util.FILTERS.FOLLOWED_TOPICS,name: $t({defaultMessage: "Followed topics"}),bold_current_selection:filters_dropdown_widget &&- filters_dropdown_widget.current_value === FILTERS.FOLLOWED_TOPICS,+ filters_dropdown_widget.current_value === views_util.FILTERS.FOLLOWED_TOPICS,},];}@@ -617,14 +611,14 @@ function filter_should_hide_row({stream_id, topic, dm_key}) {}if (- filters.has(FILTERS.FOLLOWED_TOPICS) &&+ filters.has(views_util.FILTERS.FOLLOWED_TOPICS) &&!user_topics.is_topic_followed(stream_id, topic)) {return true;}if (- filters.has(FILTERS.UNMUTED_TOPICS) &&+ filters.has(views_util.FILTERS.UNMUTED_TOPICS) &&(user_topics.is_topic_muted(stream_id, topic) || stream_data.is_muted(stream_id)) &&!user_topics.is_topic_unmuted_or_followed(stream_id, topic)) {diff --git a/web/src/views_util.js b/web/src/views_util.jsindex 8481f2845b7..7101de81159 100644--- a/web/src/views_util.js+++ b/web/src/views_util.js@@ -12,6 +12,12 @@ import * as search from "./search";import * as stream_list from "./stream_list";import * as unread_ui from "./unread_ui";+export const FILTERS = {+ ALL_TOPICS: "all_topics",+ UNMUTED_TOPICS: "unmuted_topics",+ FOLLOWED_TOPICS: "followed_topics",+};+export function show(opts) {if (narrow_state.has_shown_message_list_view) {message_lists.save_pre_narrow_offset_for_reload();