This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/components/signup-cta.js
Sam Saffron e62071830d
DEV: prefer Date.now() over new Date().getTime()
`New Date().getTime()` is both uglier and slower than `Date.now()`

`Date.now()` is available on all the browsers we support.
2020-03-26 17:36:53 +11:00

26 lines
721 B
JavaScript

import { later } from "@ember/runloop";
import Component from "@ember/component";
import { on } from "@ember/object/evented";
export default Component.extend({
action: "showCreateAccount",
actions: {
neverShow() {
this.keyValueStore.setItem("anon-cta-never", "t");
this.session.set("showSignupCta", false);
},
hideForSession() {
this.session.set("hideSignupCta", true);
this.keyValueStore.setItem("anon-cta-hidden", Date.now());
later(() => this.session.set("showSignupCta", false), 20 * 1000);
}
},
_turnOffIfHidden: on("willDestroyElement", function() {
if (this.session.get("hideSignupCta")) {
this.session.set("showSignupCta", false);
}
})
});