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/discourse-banner.js.es6
2019-05-27 10:15:39 +02:00

33 lines
865 B
JavaScript

import computed from "ember-addons/ember-computed-decorators";
export default Ember.Component.extend({
@computed("user.dismissed_banner_key", "banner.key", "hide")
visible(dismissedBannerKey, bannerKey, hide) {
dismissedBannerKey =
dismissedBannerKey || this.keyValueStore.get("dismissed_banner_key");
if (bannerKey) {
bannerKey = parseInt(bannerKey, 10);
}
if (dismissedBannerKey) {
dismissedBannerKey = parseInt(dismissedBannerKey, 10);
}
return !hide && bannerKey && dismissedBannerKey !== bannerKey;
},
actions: {
dismiss() {
if (this.user) {
this.user.dismissBanner(this.get("banner.key"));
} else {
this.set("visible", false);
this.keyValueStore.set({
key: "dismissed_banner_key",
value: this.get("banner.key")
});
}
}
}
});