settings_ui: Fix type and $ prefix of status_element argument.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2023-10-04 23:17:51 -07:00
committed by Anders Kaseorg
parent ba97611a8b
commit eb6ac7bd98
5 changed files with 15 additions and 16 deletions

View File

@@ -57,10 +57,10 @@ function rerender_ui() {
} }
} }
function change_notification_setting(setting, value, status_element) { function change_notification_setting(setting, value, $status_element) {
const data = {}; const data = {};
data[setting] = value; data[setting] = value;
settings_ui.do_settings_change(channel.patch, "/json/settings", data, status_element); settings_ui.do_settings_change(channel.patch, "/json/settings", data, $status_element);
} }
function update_desktop_icon_count_display(settings_panel) { function update_desktop_icon_count_display(settings_panel) {

View File

@@ -35,7 +35,7 @@ export function do_settings_change(
request_method: AjaxRequestHandler, request_method: AjaxRequestHandler,
url: string, url: string,
data: Parameters<AjaxRequestHandler>[0]["data"], data: Parameters<AjaxRequestHandler>[0]["data"],
status_element: string, $status_element: JQuery,
{ {
success_msg_html = strings.success_html, success_msg_html = strings.success_html,
failure_msg_html = strings.failure_html, failure_msg_html = strings.failure_html,
@@ -45,7 +45,7 @@ export function do_settings_change(
$error_msg_element, $error_msg_element,
}: RequestOpts = {}, }: RequestOpts = {},
): void { ): void {
const $spinner = $(status_element).expectOne(); const $spinner = $status_element.expectOne();
$spinner.fadeTo(0, 1); $spinner.fadeTo(0, 1);
loading.make_indicator($spinner, {text: strings.saving}); loading.make_indicator($spinner, {text: strings.saving});
const remove_after = sticky ? undefined : 1000; const remove_after = sticky ? undefined : 1000;

View File

@@ -324,7 +324,7 @@ export function stream_setting_changed(e, from_notification_settings) {
} }
const sub = get_sub_for_target(e.target); const sub = get_sub_for_target(e.target);
const status_element = from_notification_settings const $status_element = from_notification_settings
? $(e.target).closest(".subsection-parent").find(".alert-notification") ? $(e.target).closest(".subsection-parent").find(".alert-notification")
: $(`#stream_change_property_status${CSS.escape(sub.stream_id)}`); : $(`#stream_change_property_status${CSS.escape(sub.stream_id)}`);
const setting = e.target.name; const setting = e.target.name;
@@ -336,7 +336,7 @@ export function stream_setting_changed(e, from_notification_settings) {
sub[setting] = sub[setting] =
user_settings[settings_config.generalize_stream_notification_setting[setting]]; user_settings[settings_config.generalize_stream_notification_setting[setting]];
} }
stream_settings_api.set_stream_property(sub, setting, e.target.checked, status_element); stream_settings_api.set_stream_property(sub, setting, e.target.checked, $status_element);
} }
export function archive_stream(stream_id, $alert_element, $stream_row) { export function archive_stream(stream_id, $alert_element, $stream_row) {

View File

@@ -1,10 +1,10 @@
import * as channel from "./channel"; import * as channel from "./channel";
import * as settings_ui from "./settings_ui"; import * as settings_ui from "./settings_ui";
export function bulk_set_stream_property(sub_data, status_element) { export function bulk_set_stream_property(sub_data, $status_element) {
const url = "/json/users/me/subscriptions/properties"; const url = "/json/users/me/subscriptions/properties";
const data = {subscription_data: JSON.stringify(sub_data)}; const data = {subscription_data: JSON.stringify(sub_data)};
if (!status_element) { if (!$status_element) {
return channel.post({ return channel.post({
url, url,
data, data,
@@ -12,11 +12,11 @@ export function bulk_set_stream_property(sub_data, status_element) {
}); });
} }
settings_ui.do_settings_change(channel.post, url, data, status_element); settings_ui.do_settings_change(channel.post, url, data, $status_element);
return undefined; return undefined;
} }
export function set_stream_property(sub, property, value, status_element) { export function set_stream_property(sub, property, value, $status_element) {
const sub_data = {stream_id: sub.stream_id, property, value}; const sub_data = {stream_id: sub.stream_id, property, value};
bulk_set_stream_property([sub_data], status_element); bulk_set_stream_property([sub_data], $status_element);
} }

View File

@@ -1,4 +1,3 @@
import $ from "jquery";
import {z} from "zod"; import {z} from "zod";
import render_topic_muted from "../templates/topic_muted.hbs"; import render_topic_muted from "../templates/topic_muted.hbs";
@@ -125,7 +124,7 @@ export function set_user_topic_visibility_policy(
visibility_policy: number, visibility_policy: number,
from_hotkey?: boolean, from_hotkey?: boolean,
from_banner?: boolean, from_banner?: boolean,
status_element?: JQuery, $status_element?: JQuery,
): void { ): void {
const data = { const data = {
stream_id, stream_id,
@@ -134,8 +133,8 @@ export function set_user_topic_visibility_policy(
}; };
let $spinner: JQuery; let $spinner: JQuery;
if (status_element) { if ($status_element) {
$spinner = $(status_element).expectOne(); $spinner = $status_element.expectOne();
$spinner.fadeTo(0, 1); $spinner.fadeTo(0, 1);
loading.make_indicator($spinner, {text: settings_ui.strings.saving}); loading.make_indicator($spinner, {text: settings_ui.strings.saving});
} }
@@ -144,7 +143,7 @@ export function set_user_topic_visibility_policy(
url: "/json/user_topics", url: "/json/user_topics",
data, data,
success() { success() {
if (status_element) { if ($status_element) {
const remove_after = 1000; const remove_after = 1000;
const appear_after = 500; const appear_after = 500;
setTimeout(() => { setTimeout(() => {