-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Toaster.show(props, key?) #1962
Toaster.show(props, key?) #1962
Conversation
} | ||
return false; | ||
} | ||
|
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.
since Array.find()
doesn't seem to be available.
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 do it with a filter().length > 0
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.
looks good, but do we even need update
if show
can handle all the key logic?
} | ||
return false; | ||
} | ||
|
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 do it with a filter().length > 0
this.setState(prevState => ({ | ||
toasts: [options, ...prevState.toasts], | ||
})); | ||
return options.key; | ||
} | ||
|
||
public showOrUpdate(key: string, props: IToastProps) { |
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.
i wonder if this method (and, by extension, update
) is really necessary or it it can all be accomplished through show(props, key)
?
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.
Agree that this could replace show()
. The semantics for update()
are different - update()
may not result in a toast being show, while show()
and showOrUpdate()
always do. That said, I'm not sure the semantics of update()
are all that useful.
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.
I kinda dig the single show
method that'd do an update if the key already exists, seems pretty natural no? Also with the code below, I feel like showOrUpdate
should actually be called updateOrShow
for clarity
* | ||
* Callers may optionally supply a key, or a unique key will be generated. | ||
* | ||
* Returns the unique key of the new toast. |
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.
one paragraph should be sufficient. remove blank lines.
@mcintyret can we trouble you to change this feature so there's only the one |
@mcintyret any update here? the team can pick this up if you don't have the bandwidth, just let us know! |
@giladgray sorry was on vacay. Just to be clear - there would be one |
@mcintyret yes, one |
Hmm - tests passed for me locally, and the one that failed was |
@mcintyret yeah that test is not related to this change. rerunning failed jobs on circle, let's see if it's a flake. |
No luck :-( I'm seeing the same test fail in my other PR |
Mind poking this again? |
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.
code change looks fine but what's up with that test?
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.
Looks good at a glance.
fixes #1894