Skip to content

Commit

Permalink
Fix audio notifications on linux (signalapp#1526)
Browse files Browse the repository at this point in the history
This partially reverts commit 1b444a5.
Because support for system-level notification sound settings is inconsistent
across Win/Linux/OSX, do the simplest thing that will produce consistent
behavior on all platforms: suppress the system sound by always passing the
`silent: true` option, and play our own sound clip (copied from ios).

// FREEBIE
  • Loading branch information
liliakai authored and scottnonnenberg committed Oct 3, 2017
1 parent 5e6d315 commit 0b7543b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Binary file added audio/NewMessage.mp3
Binary file not shown.
6 changes: 5 additions & 1 deletion js/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
};

var enabled = false;
var sound = new Audio('audio/NewMessage.mp3');

Whisper.Notifications = new (Backbone.Collection.extend({
initialize: function() {
Expand Down Expand Up @@ -44,6 +45,9 @@
window.drawAttention();

var audioNotification = storage.get('audio-notification') || false;
if (audioNotification) {
sound.play();
}

var setting = storage.get('notification-setting') || 'message';
if (setting === SETTINGS.OFF) {
Expand Down Expand Up @@ -84,7 +88,7 @@
body : message,
icon : iconUrl,
tag : 'signal',
silent : !audioNotification
silent : true
});

notification.onclick = this.onClick.bind(this, last.get('conversationId'));
Expand Down

0 comments on commit 0b7543b

Please sign in to comment.