settings: Use variable for notification sound element.

This commit changes the click handler for playing
notification sound to use a variable instead of
directly using the element id such that we can
use the same code for realm-level settings also
by just setting the variable accordingly.
This commit is contained in:
Sahil Batra 2021-08-30 22:32:52 +05:30 committed by Tim Abbott
parent 1252d1602b
commit 079e45c7cf
1 changed files with 2 additions and 1 deletions

View File

@ -75,6 +75,7 @@ export function set_enable_marketing_emails_visibility() {
export function set_up(container, settings_object) {
const patch_url = "/json/settings";
const notification_sound_elem = $("#user-notification-sound-audio");
container.find(".notification-settings-form").on("change", "input, select", function (e) {
e.preventDefault();
e.stopPropagation();
@ -102,7 +103,7 @@ export function set_up(container, settings_object) {
container.find(".play_notification_sound").on("click", () => {
if (settings_object.notification_sound !== "none") {
$("#user-notification-sound-audio")[0].play();
notification_sound_elem[0].play();
}
});