The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/client/notifications/notification.coffee

26 lines
835 B

# Show notifications and play a sound for new messages.
# We trust the server to only send notifications for interesting messages, e.g. direct messages or
# group messages in which the user is mentioned.
Meteor.startup ->
Tracker.autorun ->
if Meteor.userId()
RocketChat.Notifications.onUser 'notification', (notification) ->
openedRoomId = undefined
if FlowRouter.getRouteName() in ['channel', 'group', 'direct']
openedRoomId = Session.get 'openedRoom'
# This logic is duplicated in /client/startup/unread.coffee.
hasFocus = readMessage.isEnable()
messageIsInOpenedRoom = openedRoomId is notification.payload.rid
if !(hasFocus and messageIsInOpenedRoom)
# Play a sound.
KonchatNotification.newMessage()
# Show a notification.
KonchatNotification.showDesktop notification