|
|
|
|
@ -124,36 +124,38 @@ const KonchatNotification = { |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Tracker.autorun(function() { |
|
|
|
|
const user = RocketChat.models.Users.findOne(Meteor.userId(), { |
|
|
|
|
fields: { |
|
|
|
|
'settings.preferences.newRoomNotification': 1, |
|
|
|
|
'settings.preferences.notificationsSoundVolume': 1 |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
const newRoomNotification = user && user.settings && user.settings.preferences && user.settings.preferences.newRoomNotification || 'door'; |
|
|
|
|
const audioVolume = user && user.settings && user.settings.preferences && user.settings.preferences.notificationsSoundVolume || 100; |
|
|
|
|
Meteor.startup(() => { |
|
|
|
|
Tracker.autorun(function() { |
|
|
|
|
const user = RocketChat.models.Users.findOne(Meteor.userId(), { |
|
|
|
|
fields: { |
|
|
|
|
'settings.preferences.newRoomNotification': 1, |
|
|
|
|
'settings.preferences.notificationsSoundVolume': 1 |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
const newRoomNotification = user && user.settings && user.settings.preferences && user.settings.preferences.newRoomNotification || 'door'; |
|
|
|
|
const audioVolume = user && user.settings && user.settings.preferences && user.settings.preferences.notificationsSoundVolume || 100; |
|
|
|
|
|
|
|
|
|
if ((Session.get('newRoomSound') || []).length > 0) { |
|
|
|
|
Tracker.nonreactive(function() { |
|
|
|
|
if (newRoomNotification !== 'none') { |
|
|
|
|
const [audio] = $(`audio#${ newRoomNotification }`); |
|
|
|
|
if (audio && audio.play) { |
|
|
|
|
audio.volume = Number((audioVolume/100).toPrecision(2)); |
|
|
|
|
return audio.play(); |
|
|
|
|
if ((Session.get('newRoomSound') || []).length > 0) { |
|
|
|
|
Meteor.defer(function() { |
|
|
|
|
if (newRoomNotification !== 'none') { |
|
|
|
|
const [audio] = $(`audio#${ newRoomNotification }`); |
|
|
|
|
if (audio && audio.play) { |
|
|
|
|
audio.volume = Number((audioVolume/100).toPrecision(2)); |
|
|
|
|
return audio.play(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
const [room] = $(`audio#${ newRoomNotification }`); |
|
|
|
|
if (!room) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (room.pause) { |
|
|
|
|
room.pause(); |
|
|
|
|
return room.currentTime = 0; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
const [room] = $(`audio#${ newRoomNotification }`); |
|
|
|
|
if (!room) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (room.pause) { |
|
|
|
|
room.pause(); |
|
|
|
|
return room.currentTime = 0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
export { KonchatNotification }; |
|
|
|
|
this.KonchatNotification = KonchatNotification; |
|
|
|
|
|