mirror of https://github.com/zulip/zulip.git
audible_notifications: Convert module to TypeScript.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
41c64ee8bb
commit
0006f4a90c
|
@ -54,7 +54,7 @@ EXEMPT_FILES = make_set(
|
||||||
"web/src/archive.js",
|
"web/src/archive.js",
|
||||||
"web/src/assets.d.ts",
|
"web/src/assets.d.ts",
|
||||||
"web/src/attachments_ui.ts",
|
"web/src/attachments_ui.ts",
|
||||||
"web/src/audible_notifications.js",
|
"web/src/audible_notifications.ts",
|
||||||
"web/src/avatar.ts",
|
"web/src/avatar.ts",
|
||||||
"web/src/billing/event_status.ts",
|
"web/src/billing/event_status.ts",
|
||||||
"web/src/billing/helpers.ts",
|
"web/src/billing/helpers.ts",
|
||||||
|
|
|
@ -2,11 +2,14 @@ import $ from "jquery";
|
||||||
|
|
||||||
import {user_settings} from "./user_settings";
|
import {user_settings} from "./user_settings";
|
||||||
|
|
||||||
export function initialize() {
|
export function initialize(): void {
|
||||||
update_notification_sound_source($("#user-notification-sound-audio"), user_settings);
|
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 notification_sound = settings_object.notification_sound;
|
||||||
const audio_file_without_extension = "/static/audio/notification_sounds/" + notification_sound;
|
const audio_file_without_extension = "/static/audio/notification_sounds/" + notification_sound;
|
||||||
$container_elem
|
$container_elem
|
|
@ -450,7 +450,7 @@ export function dispatch_normal_event(event) {
|
||||||
|
|
||||||
if (event.property === "notification_sound") {
|
if (event.property === "notification_sound") {
|
||||||
audible_notifications.update_notification_sound_source(
|
audible_notifications.update_notification_sound_source(
|
||||||
$("#realm-default-notification-sound-audio"),
|
$("audio#realm-default-notification-sound-audio"),
|
||||||
realm_user_settings_defaults,
|
realm_user_settings_defaults,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -673,7 +673,7 @@ export function dispatch_normal_event(event) {
|
||||||
if (notification_name === "notification_sound") {
|
if (notification_name === "notification_sound") {
|
||||||
// Change the sound source with the new page `notification_sound`.
|
// Change the sound source with the new page `notification_sound`.
|
||||||
audible_notifications.update_notification_sound_source(
|
audible_notifications.update_notification_sound_source(
|
||||||
$("#user-notification-sound-audio"),
|
$("audio#user-notification-sound-audio"),
|
||||||
user_settings,
|
user_settings,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -462,7 +462,7 @@ export function discard_property_element_changes(elem, for_realm_default_setting
|
||||||
switch (property_name) {
|
switch (property_name) {
|
||||||
case "notification_sound":
|
case "notification_sound":
|
||||||
audible_notifications.update_notification_sound_source(
|
audible_notifications.update_notification_sound_source(
|
||||||
$("#realm-default-notification-sound-audio"),
|
$("audio#realm-default-notification-sound-audio"),
|
||||||
{
|
{
|
||||||
notification_sound: property_value,
|
notification_sound: property_value,
|
||||||
},
|
},
|
||||||
|
|
|
@ -55,7 +55,7 @@ export function update_page(property) {
|
||||||
|
|
||||||
export function set_up() {
|
export function set_up() {
|
||||||
const $container = $(realm_default_settings_panel.container);
|
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");
|
const $notification_sound_dropdown = $container.find(".setting_notification_sound");
|
||||||
|
|
||||||
settings_display.set_up(realm_default_settings_panel);
|
settings_display.set_up(realm_default_settings_panel);
|
||||||
|
|
Loading…
Reference in New Issue