mirror of https://github.com/zulip/zulip.git
settings/muted-topic: Move list-create code to designated file.
This code better fits in `settings_muted_topics`.
This commit is contained in:
parent
eff16c934c
commit
2c4505d322
|
@ -21,10 +21,10 @@ const frontend = {
|
|||
};
|
||||
stream_data.add_sub(frontend);
|
||||
|
||||
run_test("settings", () => {
|
||||
run_test("settings", (override) => {
|
||||
muting.add_muted_topic(frontend.stream_id, "js", 1577836800);
|
||||
let set_up_topic_ui_called = false;
|
||||
muting_ui.set_up_muted_topics_ui = () => {
|
||||
let populate_list_called = false;
|
||||
override(settings_muted_topics, "populate_list", () => {
|
||||
const opts = muting.get_muted_topics();
|
||||
assert.deepEqual(opts, [
|
||||
{
|
||||
|
@ -35,14 +35,15 @@ run_test("settings", () => {
|
|||
topic: "js",
|
||||
},
|
||||
]);
|
||||
set_up_topic_ui_called = true;
|
||||
};
|
||||
populate_list_called = true;
|
||||
});
|
||||
|
||||
settings_muted_topics.reset();
|
||||
assert.equal(settings_muted_topics.loaded, false);
|
||||
|
||||
settings_muted_topics.set_up();
|
||||
assert.equal(settings_muted_topics.loaded, true);
|
||||
assert(populate_list_called);
|
||||
|
||||
const topic_click_handler = $("body").get_on_handler("click", ".settings-unmute-topic");
|
||||
assert.equal(typeof topic_click_handler, "function");
|
||||
|
@ -81,6 +82,5 @@ run_test("settings", () => {
|
|||
};
|
||||
topic_click_handler.call(topic_fake_this, event);
|
||||
assert(unmute_topic_called);
|
||||
assert(set_up_topic_ui_called);
|
||||
assert.equal(topic_data_called, 2);
|
||||
});
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import $ from "jquery";
|
||||
|
||||
import render_confirm_mute_user from "../templates/confirm_mute_user.hbs";
|
||||
import render_muted_topic_ui_row from "../templates/muted_topic_ui_row.hbs";
|
||||
import render_topic_muted from "../templates/topic_muted.hbs";
|
||||
|
||||
import * as activity from "./activity";
|
||||
|
@ -9,7 +8,6 @@ import * as channel from "./channel";
|
|||
import * as confirm_dialog from "./confirm_dialog";
|
||||
import * as feedback_widget from "./feedback_widget";
|
||||
import {$t} from "./i18n";
|
||||
import * as ListWidget from "./list_widget";
|
||||
import * as message_lists from "./message_lists";
|
||||
import * as muting from "./muting";
|
||||
import * as overlays from "./overlays";
|
||||
|
@ -21,7 +19,6 @@ import * as settings_muted_users from "./settings_muted_users";
|
|||
import * as stream_data from "./stream_data";
|
||||
import * as stream_list from "./stream_list";
|
||||
import * as stream_popover from "./stream_popover";
|
||||
import * as ui from "./ui";
|
||||
import * as unread_ui from "./unread_ui";
|
||||
|
||||
function timestamp_ms() {
|
||||
|
@ -43,7 +40,7 @@ export function rerender_on_topic_update() {
|
|||
message_lists.home.update_topic_muting_and_rerender();
|
||||
}
|
||||
if (overlays.settings_open() && settings_muted_topics.loaded) {
|
||||
set_up_muted_topics_ui();
|
||||
settings_muted_topics.populate_list();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,30 +89,6 @@ export function update_muted_topics(muted_topics) {
|
|||
unread_ui.update_unread_counts();
|
||||
}
|
||||
|
||||
export function set_up_muted_topics_ui() {
|
||||
const muted_topics = muting.get_muted_topics();
|
||||
const muted_topics_table = $("#muted_topics_table");
|
||||
const $search_input = $("#muted_topics_search");
|
||||
|
||||
ListWidget.create(muted_topics_table, muted_topics, {
|
||||
name: "muted-topics-list",
|
||||
modifier(muted_topics) {
|
||||
return render_muted_topic_ui_row({muted_topics});
|
||||
},
|
||||
filter: {
|
||||
element: $search_input,
|
||||
predicate(item, value) {
|
||||
return item.topic.toLocaleLowerCase().includes(value);
|
||||
},
|
||||
onupdate() {
|
||||
ui.reset_scrollbar(muted_topics_table.closest(".progressive-table-wrapper"));
|
||||
},
|
||||
},
|
||||
parent_container: $("#muted-topic-settings"),
|
||||
simplebar_container: $("#muted-topic-settings .progressive-table-wrapper"),
|
||||
});
|
||||
}
|
||||
|
||||
export function mute_topic(stream_id, topic) {
|
||||
const stream_name = stream_data.maybe_get_stream_name(stream_id);
|
||||
|
||||
|
|
|
@ -1,9 +1,38 @@
|
|||
import $ from "jquery";
|
||||
|
||||
import render_muted_topic_ui_row from "../templates/muted_topic_ui_row.hbs";
|
||||
|
||||
import * as ListWidget from "./list_widget";
|
||||
import * as muting from "./muting";
|
||||
import * as muting_ui from "./muting_ui";
|
||||
import * as ui from "./ui";
|
||||
|
||||
export let loaded = false;
|
||||
|
||||
export function populate_list() {
|
||||
const muted_topics = muting.get_muted_topics();
|
||||
const muted_topics_table = $("#muted_topics_table");
|
||||
const $search_input = $("#muted_topics_search");
|
||||
|
||||
ListWidget.create(muted_topics_table, muted_topics, {
|
||||
name: "muted-topics-list",
|
||||
modifier(muted_topics) {
|
||||
return render_muted_topic_ui_row({muted_topics});
|
||||
},
|
||||
filter: {
|
||||
element: $search_input,
|
||||
predicate(item, value) {
|
||||
return item.topic.toLocaleLowerCase().includes(value);
|
||||
},
|
||||
onupdate() {
|
||||
ui.reset_scrollbar(muted_topics_table.closest(".progressive-table-wrapper"));
|
||||
},
|
||||
},
|
||||
parent_container: $("#muted-topic-settings"),
|
||||
simplebar_container: $("#muted-topic-settings .progressive-table-wrapper"),
|
||||
});
|
||||
}
|
||||
|
||||
export function set_up() {
|
||||
loaded = true;
|
||||
$("body").on("click", ".settings-unmute-topic", function (e) {
|
||||
|
@ -17,7 +46,7 @@ export function set_up() {
|
|||
$row.remove();
|
||||
});
|
||||
|
||||
muting_ui.set_up_muted_topics_ui();
|
||||
populate_list();
|
||||
}
|
||||
|
||||
export function reset() {
|
||||
|
|
|
@ -125,6 +125,7 @@ EXEMPT_FILES = {
|
|||
"static/js/settings.js",
|
||||
"static/js/settings_linkifiers.js",
|
||||
"static/js/settings_playgrounds.js",
|
||||
"static/js/settings_muted_topics.js",
|
||||
"static/js/settings_muted_users.js",
|
||||
"static/js/settings_notifications.js",
|
||||
"static/js/settings_org.js",
|
||||
|
|
Loading…
Reference in New Issue