From 66bf35c029a896b84b1e27e2005e6ffe1648e06d Mon Sep 17 00:00:00 2001 From: Gabriel Engel Date: Wed, 17 Feb 2016 05:38:33 -0200 Subject: [PATCH] trying to wait for the user to be logged in to resigner the callback on messages --- client/notifications/notification.coffee | 29 ++++++++++++++---------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/client/notifications/notification.coffee b/client/notifications/notification.coffee index 42b4bfce67a..75ff3380e4c 100644 --- a/client/notifications/notification.coffee +++ b/client/notifications/notification.coffee @@ -3,19 +3,24 @@ # group messages in which the user is mentioned. Meteor.startup -> - RocketChat.Notifications.onUser 'notification', (notification) -> - openedRoomId = undefined - if FlowRouter.getRouteName() in ['channel', 'group', 'direct'] - openedRoomId = Session.get 'openedRoom' + Tracker.autorun -> - # This logic is duplicated in /client/startup/unread.coffee. - hasFocus = readMessage.isEnable() - messageIsInOpenedRoom = openedRoomId is notification.payload.rid + if Meteor.userId() - if !(hasFocus and messageIsInOpenedRoom) - # Play a sound. - KonchatNotification.newMessage() + RocketChat.Notifications.onUser 'notification', (notification) -> - # Show a notification. - KonchatNotification.showDesktop 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