audible_notifications: Convert module to TypeScript.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-10-10 15:44:18 -07:00 committed by Tim Abbott
parent 41c64ee8bb
commit 0006f4a90c
5 changed files with 11 additions and 8 deletions

View File

@ -54,7 +54,7 @@ EXEMPT_FILES = make_set(
"web/src/archive.js",
"web/src/assets.d.ts",
"web/src/attachments_ui.ts",
"web/src/audible_notifications.js",
"web/src/audible_notifications.ts",
"web/src/avatar.ts",
"web/src/billing/event_status.ts",
"web/src/billing/helpers.ts",

View File

@ -2,11 +2,14 @@ import $ from "jquery";
import {user_settings} from "./user_settings";
export function initialize() {
update_notification_sound_source($("#user-notification-sound-audio"), user_settings);
export function initialize(): void {
update_notification_sound_source($("audio#user-notification-sound-audio"), user_settings);
}
export function update_notification_sound_source($container_elem, settings_object) {
export function update_notification_sound_source(
$container_elem: JQuery<HTMLAudioElement>,
settings_object: {notification_sound: string},
): void {
const notification_sound = settings_object.notification_sound;
const audio_file_without_extension = "/static/audio/notification_sounds/" + notification_sound;
$container_elem

View File

@ -450,7 +450,7 @@ export function dispatch_normal_event(event) {
if (event.property === "notification_sound") {
audible_notifications.update_notification_sound_source(
$("#realm-default-notification-sound-audio"),
$("audio#realm-default-notification-sound-audio"),
realm_user_settings_defaults,
);
}
@ -673,7 +673,7 @@ export function dispatch_normal_event(event) {
if (notification_name === "notification_sound") {
// Change the sound source with the new page `notification_sound`.
audible_notifications.update_notification_sound_source(
$("#user-notification-sound-audio"),
$("audio#user-notification-sound-audio"),
user_settings,
);
}

View File

@ -462,7 +462,7 @@ export function discard_property_element_changes(elem, for_realm_default_setting
switch (property_name) {
case "notification_sound":
audible_notifications.update_notification_sound_source(
$("#realm-default-notification-sound-audio"),
$("audio#realm-default-notification-sound-audio"),
{
notification_sound: property_value,
},

View File

@ -55,7 +55,7 @@ export function update_page(property) {
export function set_up() {
const $container = $(realm_default_settings_panel.container);
const $notification_sound_elem = $("#realm-default-notification-sound-audio");
const $notification_sound_elem = $("audio#realm-default-notification-sound-audio");
const $notification_sound_dropdown = $container.find(".setting_notification_sound");
settings_display.set_up(realm_default_settings_panel);