Removed invalid Action.notificationDismissed firing

Summary:
If a notification is dismissed manually, the setInterval dismissal is still fired.
         This patch adds a check and removes the notification dismissal action from firing

Test Plan: none

Reviewers: ktalwar, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D1218
This commit is contained in:
Evan Morikawa 2015-05-27 12:31:07 -04:00
parent af357ef005
commit ac1ad67123

View file

@ -74,7 +74,8 @@ NotificationStore = Reflux.createStore
@_notifications[notification.tag] = notification
if notification.expiry?
timeoutVal = Math.max(0, notification.expiry - Date.now())
setTimeout(@_removeNotification(notification), timeoutVal)
timeoutId = setTimeout(@_removeNotification(notification), timeoutVal)
notification.timeoutId = timeoutId
@trigger()
@ -82,6 +83,9 @@ NotificationStore = Reflux.createStore
# above in setTimeout()
_removeNotification: (notification) -> =>
console.log "Removed #{notification}" if VERBOSE
clearTimeout(notification.timeoutId) if notification.timeoutId
delete @_notifications[notification.tag]
@trigger()