Skip to content

Commit 6031deb

Browse files
committed
Enhanced notifications - now uses gong for @messages and ding for channel messages
1 parent b9c39e9 commit 6031deb

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

app/assets/javascripts/backbone/helpers/channels.js.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class Kandan.Helpers.Channels
135135

136136
if not local and @getActiveChannelId() == activityAttributes.channel_id and activityAttributes.action == "message" and Kandan.Helpers.Utils.browserTabFocused != true
137137
Kandan.Helpers.Utils.notifyInTitle()
138-
Kandan.Plugins.Notifications.playAudioNotification()
138+
Kandan.Plugins.Notifications.playAudioNotification('channel')
139139
Kandan.Plugins.Notifications.displayNotification(activityAttributes.user.username || activityAttributes.user.email, activityAttributes.content)
140140

141141
@setPaginationData(activityAttributes.channel_id)

app/assets/javascripts/backbone/plugins/music_player.js.coffee

+7-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ class Kandan.Plugins.MusicPlayer
77
@stopRegex: /^/stop/
88
@resumeRegex: /^/resume/
99
@localSongData: false
10-
10+
@sounds: {
11+
channel: 'ding.wav'
12+
attention: 'gong.mp3'
13+
}
1114

1215
@playTemplate: _.template('<strong><a class="audio-play">playing</a> <a target="_blank" href="<%- url %>"><%- url %></a></strong>')
1316
@stopTemplate: _.template('<strong><a class="audio-play">stopping</a> the music.')
@@ -170,8 +173,9 @@ class Kandan.Plugins.MusicPlayer
170173
if @audioChannel(channelId)?
171174
@unmute(channelId)
172175

173-
@playAudioNotice: ->
174-
url = @localFileUrl('ding.wav')
176+
@playAudioNotice: (type)->
177+
sound = @sounds[type] || 'ding.wav'
178+
url = @localFileUrl(sound)
175179
player = $('.audio_private')[0]
176180
player.setAttribute('src', url)
177181
player.play()

app/assets/javascripts/backbone/plugins/notifications.js.coffee

+8-6
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class Kandan.Plugins.Notifications
7676
@onPopupNotificationsEnabled: ()->
7777
if @webkitNotificationsEnabled()
7878
@enablePopupNotifications()
79-
79+
8080
return
8181

8282
# If you are wondering why the kandan icon is not displayed on OS X this is the reason:
@@ -108,7 +108,7 @@ class Kandan.Plugins.Notifications
108108
@sound_notifications_enabled = true
109109
$(".sound-notifications .enable-sound-notifications").remove()
110110
$(".notification.sound-notifications").append(@disable_sound_notifications_template())
111-
111+
112112
return
113113

114114
@disableSoundNotifications: ()->
@@ -118,7 +118,9 @@ class Kandan.Plugins.Notifications
118118
$(".notification.sound-notifications").append(@enable_sound_notifications_template())
119119
return
120120

121-
@playAudioNotification: ()->
122-
if @sound_notifications_enabled
123-
Kandan.Plugins.MusicPlayer.playAudioNotice()
124-
return
121+
@playAudioNotification: (type)->
122+
if @sound_notifications_enabled and not @isPlaying
123+
@isPlaying = true
124+
setTimeout (=> @isPlaying = false), 1000
125+
Kandan.Plugins.MusicPlayer.playAudioNotice(type)
126+
return

app/assets/javascripts/backbone/views/show_activity.js.coffee

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class Kandan.Views.ShowActivity extends Backbone.View
2626

2727
if user_mention_regex.test(@compiledTemplate) || all_mention_regex.test(@compiledTemplate)
2828
$(@el).addClass("mentioned_user")
29+
Kandan.Plugins.Notifications?.playAudioNotification('attention')
2930

3031
if activity.id == undefined
3132
$(@el).attr("id", "activity-c#{activity.cid}")

0 commit comments

Comments
 (0)