From 0006f4a90c244472afb74059805b69c667004a0b Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 10 Oct 2023 15:44:18 -0700 Subject: [PATCH] audible_notifications: Convert module to TypeScript. Signed-off-by: Anders Kaseorg --- tools/test-js-with-node | 2 +- ...audible_notifications.js => audible_notifications.ts} | 9 ++++++--- web/src/server_events_dispatch.js | 4 ++-- web/src/settings_org.js | 2 +- web/src/settings_realm_user_settings_defaults.js | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) rename web/src/{audible_notifications.js => audible_notifications.ts} (70%) diff --git a/tools/test-js-with-node b/tools/test-js-with-node index f28d7cfa2f..4aee6b6639 100755 --- a/tools/test-js-with-node +++ b/tools/test-js-with-node @@ -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", diff --git a/web/src/audible_notifications.js b/web/src/audible_notifications.ts similarity index 70% rename from web/src/audible_notifications.js rename to web/src/audible_notifications.ts index 46fec9132e..173e79891b 100644 --- a/web/src/audible_notifications.js +++ b/web/src/audible_notifications.ts @@ -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, + 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 diff --git a/web/src/server_events_dispatch.js b/web/src/server_events_dispatch.js index a766d31cd0..e5b0b7fdb6 100644 --- a/web/src/server_events_dispatch.js +++ b/web/src/server_events_dispatch.js @@ -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, ); } diff --git a/web/src/settings_org.js b/web/src/settings_org.js index 50b5991a57..8f065d23a7 100644 --- a/web/src/settings_org.js +++ b/web/src/settings_org.js @@ -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, }, diff --git a/web/src/settings_realm_user_settings_defaults.js b/web/src/settings_realm_user_settings_defaults.js index f3a6a30ae1..0826cecd6c 100644 --- a/web/src/settings_realm_user_settings_defaults.js +++ b/web/src/settings_realm_user_settings_defaults.js @@ -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);