Skip to content

notifications state not clearing with autoDismiss #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
denen99 opened this issue Nov 11, 2017 · 6 comments
Open

notifications state not clearing with autoDismiss #57

denen99 opened this issue Nov 11, 2017 · 6 comments

Comments

@denen99
Copy link

denen99 commented Nov 11, 2017

Hi -

I have a situation where i call a Notifications.success() and the notifications state in redux (using autoDismiss) does not auto remove. This causes a double notification to show up when the next notification is triggered.

It doesnt happen every time but every so often i see this case. autoDismiss is set to 5 and the next event happens well after 5 seconds.

Any ideas ?

@SheikhG1900
Copy link

You probably want to update previous notification. please see the demo here.

@denen99
Copy link
Author

denen99 commented Apr 20, 2018

Thanks but shouldnt the autoDismiss not require the removeNotification() to be called ?

@SheikhG1900
Copy link

Why do you want. removeNotification to be called? Share the usecase.
In general we usually want to update previous notification. If previous notification was delayed to get closed by couple of second it would not be considered a big problem. The point is two notifications of same ID should not be shown simultaneously.

@denen99
Copy link
Author

denen99 commented Apr 22, 2018

I guess i was just asking if autoDismiss should automatically called removeNotification and whether or not there was a potential race condition. We are seeing issues intermittently if we call Notifications.success() and then later call it again, we see the previous message stacked underneath again so it looks like a double notification.

@SheikhG1900
Copy link

Yes this is probably due to race condition. In my opinion redux based logic could have been improved. I don't understand why are we keeping all notifications in redux. We should have used redux just to send messages to React component and after message consumed we should have clear all notifications from the redux store. I have implemented this way and now not having this kind of issues.
Here is my source code for better understanding.
https://github.com/sheikhG1900/react-notifier-system-redux

@denen99
Copy link
Author

denen99 commented May 23, 2018

I think i figured out whats going on. if i click an action, a message gets dispatched, but before the autoDismiss fires , I click to another page. The notification gets stuck in the store... Need to see how the autoDismiss logic is managed, i guess the setTimeout() is getting cancelled and the message is getting stuck.

https://github.com/igorprado/react-notification-system/blob/master/src/helpers.js#L15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants