Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

settings_ui: Fix type and $ prefix of status_element argument.

Anders Kaseorgeb6ac7bd9808
diff --git a/web/src/settings_notifications.js b/web/src/settings_notifications.js
index 23ce3150204..fee688f8f79 100644
--- a/web/src/settings_notifications.js
+++ b/web/src/settings_notifications.js
@@ -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 = {};
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) {
diff --git a/web/src/settings_ui.ts b/web/src/settings_ui.ts
index a9d3863dc2f..906025da9d4 100644
--- a/web/src/settings_ui.ts
+++ b/web/src/settings_ui.ts
@@ -35,7 +35,7 @@ export function do_settings_change(
request_method: AjaxRequestHandler,
url: string,
data: Parameters<AjaxRequestHandler>[0]["data"],
- status_element: string,
+ $status_element: JQuery,
{
success_msg_html = strings.success_html,
failure_msg_html = strings.failure_html,
@@ -45,7 +45,7 @@ export function do_settings_change(
$error_msg_element,
}: RequestOpts = {},
): void {
- const $spinner = $(status_element).expectOne();
+ const $spinner = $status_element.expectOne();
$spinner.fadeTo(0, 1);
loading.make_indicator($spinner, {text: strings.saving});
const remove_after = sticky ? undefined : 1000;
diff --git a/web/src/stream_edit.js b/web/src/stream_edit.js
index 077b3781ca7..8afb92b38e1 100644
--- a/web/src/stream_edit.js
+++ b/web/src/stream_edit.js
@@ -324,7 +324,7 @@ export function stream_setting_changed(e, from_notification_settings) {
}
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")
: $(`#stream_change_property_status${CSS.escape(sub.stream_id)}`);
const setting = e.target.name;
@@ -336,7 +336,7 @@ export function stream_setting_changed(e, from_notification_settings) {
sub[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) {
diff --git a/web/src/stream_settings_api.js b/web/src/stream_settings_api.js
index 512251a9fe0..e5b6198c6a0 100644
--- a/web/src/stream_settings_api.js
+++ b/web/src/stream_settings_api.js
@@ -1,10 +1,10 @@
import * as channel from "./channel";
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 data = {subscription_data: JSON.stringify(sub_data)};
- if (!status_element) {
+ if (!$status_element) {
return channel.post({
url,
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;
}
-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};
- bulk_set_stream_property([sub_data], status_element);
+ bulk_set_stream_property([sub_data], $status_element);
}
diff --git a/web/src/user_topics.ts b/web/src/user_topics.ts
index 3a191fc0e49..e0f0facf021 100644
--- a/web/src/user_topics.ts
+++ b/web/src/user_topics.ts
@@ -1,4 +1,3 @@
-import $ from "jquery";
import {z} from "zod";
import render_topic_muted from "../templates/topic_muted.hbs";
@@ -125,7 +124,7 @@ export function set_user_topic_visibility_policy(
visibility_policy: number,
from_hotkey?: boolean,
from_banner?: boolean,
- status_element?: JQuery,
+ $status_element?: JQuery,
): void {
const data = {
stream_id,
@@ -134,8 +133,8 @@ export function set_user_topic_visibility_policy(
};
let $spinner: JQuery;
- if (status_element) {
- $spinner = $(status_element).expectOne();
+ if ($status_element) {
+ $spinner = $status_element.expectOne();
$spinner.fadeTo(0, 1);
loading.make_indicator($spinner, {text: settings_ui.strings.saving});
}
@@ -144,7 +143,7 @@ export function set_user_topic_visibility_policy(
url: "/json/user_topics",
data,
success() {
- if (status_element) {
+ if ($status_element) {
const remove_after = 1000;
const appear_after = 500;
setTimeout(() => {