Skip to content

Commit db916f4

Browse files
committed
Add notification sound
1 parent 709e6ad commit db916f4

9 files changed

Lines changed: 33 additions & 13 deletions

File tree

src/chat/interface/chatinterface.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,9 @@ var clientSettings = require("./clientsettings.js");
540540
}
541541
if (clientSettings.getSetting("CHAT_NOTIFY")) {
542542
notify.sendIfNotOnScreen(
543-
"New message!",
544-
`${json.displayName}: ${shtml.bracketCodeRemoval(json.message)}`
543+
"New message",
544+
`${json.displayName}: ${shtml.bracketCodeRemoval(json.message)}`,
545+
"New message"
545546
);
546547
}
547548
}

src/chat/interface/commands/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,4 +608,10 @@ com.importantMessage = function (messageText) {
608608
}, 10000);
609609
};
610610

611+
com.cheeseStorm = function () {
612+
if (!clientSettings.getSetting("JOKE_COMMANDS")) {
613+
return;
614+
}
615+
};
616+
611617
module.exports = com;

src/chat/interface/notifications/index.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ var elements = require("../../../gp2/elements.js");
22
var dialogs = require("../../../dialogs.js");
33
var sws = require("../sharedwebsocket.js");
44
var audio = require("../../../audio.js");
5+
var sounds = require("../sounds.js");
56
var clientSettings = require("../clientsettings.js");
67
var accountHelper = require("../../../accounthelper/index.js");
78
var notify = require("../notify.js");
@@ -81,7 +82,7 @@ class RealTimeNotifications {
8182
{
8283
element: "p",
8384
textContent:
84-
"You'll recive notifications actions such as invites to people from other rooms.",
85+
"You'll recive notifications here from certain things, such as invites to chatrooms.",
8586
},
8687
{
8788
element: "p",
@@ -228,23 +229,31 @@ class RealTimeNotifications {
228229
this.notifications = this.notifications.slice(-100);
229230
this.loadNotifications();
230231
var notification = json.notification;
232+
if (clientSettings.getSetting("UI_SOUNDS")) {
233+
sounds.play("notificationBell", 1);
234+
}
231235
if (
232236
notification.type == "test" &&
233237
clientSettings.getSetting("BELL_NOTIFCATIONS")
234238
) {
235-
notify.sendIfNotOnScreen("notification", "Test notification");
239+
notify.sendIfNotOnScreen(
240+
"Testing",
241+
"Test notification",
242+
"New notification received"
243+
);
236244
}
237245
if (
238246
notification.type == "invite" &&
239247
clientSettings.getSetting("BELL_NOTIFCATIONS")
240248
) {
241249
notify.sendIfNotOnScreen(
242-
"notification",
250+
"Chatroom Invitation",
243251
"@" +
244252
notification.from +
245253
' has invited you to the chat room "' +
246254
notification.roomName +
247-
'"'
255+
'"',
256+
"Invited to " + notification.roomName
248257
);
249258
}
250259
}

src/chat/interface/notifications/invitenotifcation.js

Whitespace-only changes.

src/chat/interface/notify.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ var notify = {};
66

77
var lastNotifcation = null;
88

9-
notify.sendIfNotOnScreen = function (tag, message) {
9+
notify.sendIfNotOnScreen = function (tag, message, title = "Random Rants +") {
1010
if (document.visibilityState !== "visible") {
1111
if (lastNotifcation) {
1212
try {
1313
lastNotifcation.close();
1414
} catch (e) {}
1515
}
16-
lastNotifcation = new Notification("Random Rants +", {
16+
lastNotifcation = new Notification(title, {
1717
icon: "favicon.png",
1818
tag: tag,
1919
body: message,

src/chat/interface/sounds.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,21 @@ soundManager.load = async function () {
2424
var a = await fetch("external/uisound.json");
2525
var soundURLS = await a.json();
2626

27-
var soundsToLoad = ["error", "notify", "type", "select"];
27+
var soundsToLoad = ["error", "notify", "type", "select", "notificationBell"];
2828

2929
for (var soundName of soundsToLoad) {
3030
var data;
3131
data = await audio.loadSoundFromURL(soundURLS[soundName]);
3232
//loadSoundFromURL may fail and return null without throwing errors.
3333
//although no errors would be thrown trying to play null, it would lead to unexpected bugs
3434
if (!data) {
35-
data = await audio.loadSoundFromURL(soundURLS[soundName + "Backup"]);
35+
if (soundURLS[soundName + "Backup"]) {
36+
data = await audio.loadSoundFromURL(soundURLS[soundName + "Backup"]);
37+
}
3638
}
3739
if (!data) {
3840
console.warn(
39-
`❌ UI sound "${soundName}" failed to load from both primary and backup.`,
41+
`❌ UI sound "${soundName}" failed to load from both primary and backup. (if provided)`
4042
);
4143
}
4244
sounds[soundName] = data;

wpstatic/external/uisound.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@
77
"errorBackup": "uisounds/error.mp3",
88
"notifyBackup": "uisounds/pop.mp3",
99
"selectBackup": "uisounds/select.mp3",
10-
"typeBackup": "uisounds/keyboard.mp3"
10+
"typeBackup": "uisounds/keyboard.mp3",
11+
12+
"notificationBell": "uisounds/notification.wav"
1113
}
467 KB
Loading

wpstatic/version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"timestamp":"1761232736672"}
1+
{"timestamp":"1761234814866"}

0 commit comments

Comments
 (0)