notification: Rename notification-sound audio and child elements.

This is a prep commit for adding UI for realm-level defaults
of user settings.
This commit renames notification-sound-audio element to
user-notification-sound-audio because we will be adding similar
element for realm-level default of user settings also.

We also change the child elements to have current id as their
class for the same reason.
This commit is contained in:
Sahil Batra 2021-08-09 18:27:06 +05:30 committed by Tim Abbott
parent 7b79980be9
commit 02ce8531cc
3 changed files with 13 additions and 8 deletions

View File

@ -95,13 +95,18 @@ export function initialize() {
function update_notification_sound_source() { function update_notification_sound_source() {
const notification_sound = user_settings.notification_sound; const notification_sound = user_settings.notification_sound;
const audio_file_without_extension = "/static/audio/notification_sounds/" + notification_sound; const audio_file_without_extension = "/static/audio/notification_sounds/" + notification_sound;
$("#notification-sound-source-ogg").attr("src", `${audio_file_without_extension}.ogg`); const container_elem = $("#user-notification-sound-audio");
$("#notification-sound-source-mp3").attr("src", `${audio_file_without_extension}.mp3`); container_elem
.find(".notification-sound-source-ogg")
.attr("src", `${audio_file_without_extension}.ogg`);
container_elem
.find(".notification-sound-source-mp3")
.attr("src", `${audio_file_without_extension}.mp3`);
if (notification_sound !== "none") { if (notification_sound !== "none") {
// Load it so that it is ready to be played; without this the old sound // Load it so that it is ready to be played; without this the old sound
// is played. // is played.
$("#notification-sound-audio")[0].load(); container_elem[0].load();
} }
} }
@ -503,7 +508,7 @@ export function received_messages(messages) {
}); });
} }
if (should_send_audible_notification(message)) { if (should_send_audible_notification(message)) {
$("#notification-sound-audio")[0].play(); $("#user-notification-sound-audio")[0].play();
} }
} }
} }

View File

@ -103,7 +103,7 @@ export function set_up() {
container.find(".play_notification_sound").on("click", () => { container.find(".play_notification_sound").on("click", () => {
if (user_settings.notification_sound !== "none") { if (user_settings.notification_sound !== "none") {
$("#notification-sound-audio")[0].play(); $("#user-notification-sound-audio")[0].play();
} }
}); });

View File

@ -204,9 +204,9 @@
<div class="left-sidebar-modal-holder"></div> <div class="left-sidebar-modal-holder"></div>
<div class="mute-user-modal-holder"></div> <div class="mute-user-modal-holder"></div>
<div id="move-a-topic-modal-holder"></div> <div id="move-a-topic-modal-holder"></div>
<audio id="notification-sound-audio"> <audio id="user-notification-sound-audio">
<source id="notification-sound-source-ogg" type="audio/ogg" /> <source class="notification-sound-source-ogg" type="audio/ogg" />
<source id="notification-sound-source-mp3" type="audio/mpeg" /> <source class="notification-sound-source-mp3" type="audio/mpeg" />
</audio> </audio>
</div> </div>
{% endblock %} {% endblock %}