mirror of https://github.com/zulip/zulip.git
user_topic_popover: Convert module to TypeScript.
This commit is contained in:
parent
a601715e37
commit
ab03c74314
|
@ -292,7 +292,7 @@ EXEMPT_FILES = make_set(
|
|||
"web/src/user_sort.ts",
|
||||
"web/src/user_status.ts",
|
||||
"web/src/user_status_ui.ts",
|
||||
"web/src/user_topic_popover.js",
|
||||
"web/src/user_topic_popover.ts",
|
||||
"web/src/user_topics.ts",
|
||||
"web/src/user_topics_ui.ts",
|
||||
"web/src/views_util.ts",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import $ from "jquery";
|
||||
import assert from "minimalistic-assert";
|
||||
|
||||
import render_change_visibility_policy_popover from "../templates/popovers/change_visibility_policy_popover.hbs";
|
||||
|
||||
|
@ -8,7 +9,7 @@ import {parse_html} from "./ui_util";
|
|||
import * as user_topics from "./user_topics";
|
||||
import * as util from "./util";
|
||||
|
||||
export function initialize() {
|
||||
export function initialize(): void {
|
||||
popover_menus.register_popover_menu(".change_visibility_policy", {
|
||||
theme: "popover-menu",
|
||||
placement: "bottom",
|
||||
|
@ -28,15 +29,18 @@ export function initialize() {
|
|||
popover_menus.popover_instances.change_visibility_policy = instance;
|
||||
popover_menus.on_show_prep(instance);
|
||||
const $elt = $(instance.reference).closest(".change_visibility_policy").expectOne();
|
||||
const stream_id = $elt.attr("data-stream-id");
|
||||
const topic_name = $elt.attr("data-topic-name");
|
||||
const stream_id_str = $elt.attr("data-stream-id");
|
||||
$elt.addClass("visibility-policy-popover-visible");
|
||||
assert(stream_id_str !== undefined);
|
||||
|
||||
const stream_id = Number.parseInt(stream_id_str, 10);
|
||||
const topic_name = $elt.attr("data-topic-name")!;
|
||||
|
||||
instance.setContent(
|
||||
parse_html(
|
||||
render_change_visibility_policy_popover(
|
||||
popover_menus_data.get_change_visibility_policy_popover_content_context(
|
||||
Number.parseInt(stream_id, 10),
|
||||
stream_id,
|
||||
topic_name,
|
||||
),
|
||||
),
|
||||
|
@ -46,8 +50,11 @@ export function initialize() {
|
|||
onMount(instance) {
|
||||
const $popper = $(instance.popper);
|
||||
const $elt = $(instance.reference).closest(".change_visibility_policy").expectOne();
|
||||
const stream_id = Number.parseInt($elt.attr("data-stream-id"), 10);
|
||||
const topic_name = $elt.attr("data-topic-name");
|
||||
const stream_id_str = $elt.attr("data-stream-id");
|
||||
assert(stream_id_str !== undefined);
|
||||
|
||||
const stream_id = Number.parseInt(stream_id_str, 10);
|
||||
const topic_name = $elt.attr("data-topic-name")!;
|
||||
|
||||
if (!stream_id) {
|
||||
popover_menus.hide_current_popover_if_visible(instance);
|
||||
|
@ -58,11 +65,11 @@ export function initialize() {
|
|||
const start_time = Date.now();
|
||||
|
||||
const visibility_policy = Number.parseInt(
|
||||
$(e.currentTarget).attr("data-visibility-policy"),
|
||||
$(e.currentTarget).attr("data-visibility-policy")!,
|
||||
10,
|
||||
);
|
||||
|
||||
const success_cb = () => {
|
||||
const success_cb = (): void => {
|
||||
setTimeout(
|
||||
() => {
|
||||
popover_menus.hide_current_popover_if_visible(instance);
|
||||
|
@ -71,7 +78,8 @@ export function initialize() {
|
|||
);
|
||||
};
|
||||
|
||||
const error_cb = () => {
|
||||
const error_cb = (): void => {
|
||||
assert(stream_id !== undefined);
|
||||
const prev_visibility_policy = user_topics.get_topic_visibility_policy(
|
||||
stream_id,
|
||||
topic_name,
|
||||
|
@ -86,7 +94,7 @@ export function initialize() {
|
|||
util.get_remaining_time(start_time, 500),
|
||||
);
|
||||
};
|
||||
|
||||
assert(stream_id !== undefined);
|
||||
user_topics.set_user_topic_visibility_policy(
|
||||
stream_id,
|
||||
topic_name,
|
||||
|
@ -105,7 +113,7 @@ export function initialize() {
|
|||
.expectOne()
|
||||
.removeClass("visibility-policy-popover-visible");
|
||||
instance.destroy();
|
||||
popover_menus.popover_instances.change_visibility_policy = undefined;
|
||||
popover_menus.popover_instances.change_visibility_policy = null;
|
||||
|
||||
// If the reference is in recent view / inbox, we would ideally restore focus
|
||||
// to the reference icon here but we don't do that because there are a lot of
|
Loading…
Reference in New Issue