2021-03-11 05:43:45 +01:00
|
|
|
import $ from "jquery";
|
|
|
|
|
2021-04-27 12:09:08 +02:00
|
|
|
import render_muted_topic_ui_row from "../templates/muted_topic_ui_row.hbs";
|
|
|
|
|
|
|
|
import * as ListWidget from "./list_widget";
|
2021-07-08 20:36:52 +02:00
|
|
|
import * as muted_topics_ui from "./muted_topics_ui";
|
2021-04-27 12:09:08 +02:00
|
|
|
import * as ui from "./ui";
|
2022-08-14 15:33:13 +02:00
|
|
|
import * as user_topics from "./user_topics";
|
2021-02-28 00:41:32 +01:00
|
|
|
|
2021-02-10 17:06:24 +01:00
|
|
|
export let loaded = false;
|
2020-08-01 03:43:15 +02:00
|
|
|
|
2021-04-27 12:09:08 +02:00
|
|
|
export function populate_list() {
|
2022-08-14 15:33:13 +02:00
|
|
|
const all_muted_topics = user_topics.get_muted_topics();
|
2022-01-25 11:36:19 +01:00
|
|
|
const $muted_topics_table = $("#muted_topics_table");
|
2021-04-27 12:09:08 +02:00
|
|
|
const $search_input = $("#muted_topics_search");
|
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
ListWidget.create($muted_topics_table, all_muted_topics, {
|
2021-04-27 12:09:08 +02:00
|
|
|
name: "muted-topics-list",
|
2022-02-21 18:25:49 +01:00
|
|
|
modifier(muted_topic) {
|
|
|
|
return render_muted_topic_ui_row({muted_topic});
|
2021-04-27 12:09:08 +02:00
|
|
|
},
|
|
|
|
filter: {
|
2022-01-25 11:36:19 +01:00
|
|
|
$element: $search_input,
|
2021-04-27 12:09:08 +02:00
|
|
|
predicate(item, value) {
|
|
|
|
return item.topic.toLocaleLowerCase().includes(value);
|
|
|
|
},
|
|
|
|
onupdate() {
|
2022-01-25 11:36:19 +01:00
|
|
|
ui.reset_scrollbar($muted_topics_table.closest(".progressive-table-wrapper"));
|
2021-04-27 12:09:08 +02:00
|
|
|
},
|
|
|
|
},
|
2022-01-25 11:36:19 +01:00
|
|
|
$parent_container: $("#muted-topic-settings"),
|
|
|
|
$simplebar_container: $("#muted-topic-settings .progressive-table-wrapper"),
|
2021-04-27 12:09:08 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-02-10 17:06:24 +01:00
|
|
|
export function set_up() {
|
|
|
|
loaded = true;
|
2020-07-15 01:29:15 +02:00
|
|
|
$("body").on("click", ".settings-unmute-topic", function (e) {
|
2019-11-02 00:06:25 +01:00
|
|
|
const $row = $(this).closest("tr");
|
2020-10-07 09:17:30 +02:00
|
|
|
const stream_id = Number.parseInt($row.attr("data-stream-id"), 10);
|
2019-11-02 00:06:25 +01:00
|
|
|
const topic = $row.attr("data-topic");
|
2017-04-06 16:56:52 +02:00
|
|
|
|
2021-04-17 13:59:43 +02:00
|
|
|
e.stopPropagation();
|
2018-12-14 17:20:35 +01:00
|
|
|
|
2021-07-08 20:36:52 +02:00
|
|
|
muted_topics_ui.unmute_topic(stream_id, topic);
|
2017-04-06 16:56:52 +02:00
|
|
|
});
|
|
|
|
|
2021-04-27 12:09:08 +02:00
|
|
|
populate_list();
|
2021-02-10 17:06:24 +01:00
|
|
|
}
|
2020-07-12 00:13:47 +02:00
|
|
|
|
2021-02-10 17:06:24 +01:00
|
|
|
export function reset() {
|
|
|
|
loaded = false;
|
|
|
|
}
|