From ac1ad67123f53b78c704212c6cc8384e41a4039e Mon Sep 17 00:00:00 2001 From: Evan Morikawa Date: Wed, 27 May 2015 12:31:07 -0400 Subject: [PATCH] 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 --- .../notifications/lib/notifications-store.coffee | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal_packages/notifications/lib/notifications-store.coffee b/internal_packages/notifications/lib/notifications-store.coffee index 26a1abb65..01f7b7062 100644 --- a/internal_packages/notifications/lib/notifications-store.coffee +++ b/internal_packages/notifications/lib/notifications-store.coffee @@ -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()