-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Fix issue with "Infinity" value not working #12980
Fix issue with "Infinity" value not working #12980
Conversation
…s "hide 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.
LGTM
src/ui/public/notify/notifier.js
Outdated
@@ -63,7 +63,7 @@ function timerCanceler(notif, cb = _.noop, key) { | |||
function startNotifTimer(notif, cb) { | |||
const interval = 1000; | |||
|
|||
if (notif.lifetime === Infinity || notif.lifetime === 0) { | |||
if (notif.lifetime === 'Infinity' || notif.lifetime === Infinity || notif.lifetime === 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.
This doesn't seem like the right place to handle this case. The reason the string 'Infinity' is intended to be supported in this PR is because of a use case with the advanced settings UI itself, so it seems like this value should be serialized there long before it gets passed to the notifier.
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 can appreciate that, but I think the benefit of doing it here is that every place that uses the advanced config options can ignore the output and hand it off here. Unless we want to provide a getter on the config object that can parse this for every caller.
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.
LGTM
@@ -125,6 +125,8 @@ will set the initial value if one is not already set.`); | |||
const currentValue = config.isDefault(key) ? defaultValue : userValue; | |||
if (type === 'json') { | |||
return JSON.parse(currentValue); | |||
} else if (type === 'number') { | |||
return parseFloat(currentValue); |
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.
👍 This was easier than I expected. Kudos on finding this part.
Typing in "Infinity" into an advanced setting makes it a string, not the special javascript "Infinity" value, so look for both when determine lifetime notification. Also, treat negative numbers as "hide this notification".
Fixes #7565
Note to test this, you have to refresh the page after changing the advanced setting, to get the new notification value picked up.
cc @LeeDr