-
Notifications
You must be signed in to change notification settings - Fork 78
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
Allow setting the ID of the notification manually #8
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix this and it's will be perfect :)
@@ -17,7 +17,9 @@ const REMOVE_NOTIFICATION = 'REMOVE_NOTIFICATION'; | |||
* @returns {Object} notification | |||
*/ | |||
export const addNotification = (notification) => (dispatch) => { | |||
notification.id = new Date().getTime(); | |||
if (notification.id === undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use if (!notification.id) {
here, it will prevent empty string, null
case, etc...
As you can see, L21 is no more covered because we set notification.id
to null
in the test case : https://coveralls.io/builds/8020458/source?filename=src%2Fstore%2Fnotifications.js#L21
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. Could you also update section of the API documentation please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please, use Number
or String
instead of Object
for the type of the notification ID . Of course in JS, Number and String are object but it's clearer. When we talk about object, we expect : {}
.
@@ -113,12 +114,13 @@ updateNotification(notification); | |||
|
|||
| Parameter | Type | Description | | |||
| ------------ | -------- | ----------- | | |||
| notification | Object | A [notification](https://github.com/LouisBarranqueiro/reapop/blob/master/docs/api.md#notification-object-properties-1) object | | |||
| notification | Object | A [notification](https://github.com/LouisBarranqueiro/reapop/blob/master/docs/api.md#notification-object-properties-1) object or ID of the notification | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why? If you pass a notification ID, nothing gonna change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, my bad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks man, for your contribution :)
Great, thanks for merging. When should I expect to see this on NPM? |
Just published :) |
This PR allows to set manually the identifier of the notification. The uniqueness of the ID in this case is the responsibility of the user. This does not change any existing behaviour.
Made for this issue: #6
I am not sure on where to add the documentation about this feature, please point me