Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Trigger the 'new' badge based on the locale/launch filtered experiment list #1984

Merged
merged 1 commit into from Jan 6, 2017

Conversation

jaredhirsch
Copy link
Member

Unfortunately, the 'new' badge isn't recalculated dynamically when the user's language preference changes. But it will only trigger in the case where the language isn't blocked and the launch_date is in the future. We could dynamically recalculate the 'new' badge, but that would expand the scope of this patch.

Fixes #1973.

const created = new Date(experiment.created);
const launched = experiment.launch_date && new Date(experiment.launch_date);
return (created.getTime() > store.toolbarButtonLastClicked) ||
(launched.getTime() > store.toolbarButtonLastClicked);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

launched might not be a Date here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thanks

const created = new Date(experiment.created);
const launched = experiment.launch_date && new Date(experiment.launch_date);
return (created.getTime() > store.toolbarButtonLastClicked) ||
(launched.getTime() > store.toolbarButtonLastClicked);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused on this line.
I think line 217 above is saying experiment.launch_date && which looks like it could almost return a false/undefined if launch_date wasn't somehow defined for an experiment.
Which if that boolean logic fails, and launched doesn't get set to a Date object, this line could fail as .getTime() would be trying to access a non-Date object here.

Maybe?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, dcoates found the same potential bug 👍

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

Successfully merging this pull request may close these issues.

None yet

3 participants