Skip to content

Commit

Permalink
Keep track of audio notifications too, to avoid repetitive sounds for…
Browse files Browse the repository at this point in the history
… the same alarm.
  • Loading branch information
yunosh committed Apr 14, 2014
1 parent a4ffe44 commit b2bf29b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
7 changes: 7 additions & 0 deletions framework/Core/js/hordecore.js
Expand Up @@ -24,6 +24,7 @@ var HordeCore = {
// submit_frame, text

alarms: [],
audios: [],
base: null,
handlers: {},
jsfiles: [],
Expand Down Expand Up @@ -331,6 +332,12 @@ var HordeCore = {

switch (m.type) {
case 'audio':
// Only play one instance of an alarm sound.
if (this.audios.include(m.flags.id)) {
break;
}
this.audios.push(m.flags.id);

if (!this.audio) {
this.audio = new Element('AUDIO');
$(document.body).insert(this.audio);
Expand Down
14 changes: 10 additions & 4 deletions framework/Core/lib/Horde/Core/Alarm/Handler/Notify.php
Expand Up @@ -33,13 +33,19 @@ public function notify(array $alarm)
{
global $notification;

$notification->push($alarm['title'], 'horde.alarm', array(
'alarm' => $alarm
));
$notification->push(
$alarm['title'],
'horde.alarm',
array('alarm' => $alarm)
);
if (!empty($alarm['params']['notify']['sound']) &&
!isset($this->_soundPlayed[$alarm['params']['notify']['sound']])) {
$notification->attach('audio');
$notification->push($alarm['params']['notify']['sound'], 'audio');
$notification->push(
$alarm['params']['notify']['sound'],
'audio',
array('id' => $alarm['id'])
);
$this->_soundPlayed[$alarm['params']['notify']['sound']] = true;
}
}
Expand Down

0 comments on commit b2bf29b

Please sign in to comment.