FEATURE: Store dismissed state of topic nav popups (#15570)
The dismissed state will be stored between sessions if popupId attribute is present.
This commit is contained in:
parent
376799b1a4
commit
4951900bbc
|
@ -1,12 +1,43 @@
|
|||
import Component from "@ember/component";
|
||||
import { action } from "@ember/object";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
|
||||
export default Component.extend({
|
||||
tagName: "",
|
||||
popupId: null,
|
||||
hidden: false,
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
|
||||
if (this.popupKey) {
|
||||
const value = this.keyValueStore.getItem(this.popupKey);
|
||||
if (value === true || value > +new Date()) {
|
||||
this.set("hidden", true);
|
||||
} else {
|
||||
this.keyValueStore.removeItem(this.popupKey);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@discourseComputed("popupId")
|
||||
popupKey(popupId) {
|
||||
if (popupId) {
|
||||
return `dismiss_topic_nav_popup_${popupId}`;
|
||||
}
|
||||
},
|
||||
|
||||
@action
|
||||
close() {
|
||||
this.set("hidden", true);
|
||||
|
||||
if (this.popupKey) {
|
||||
if (this.dismissDuration) {
|
||||
const expiry = +new Date() + this.dismissDuration;
|
||||
this.keyValueStore.setItem(this.popupKey, expiry);
|
||||
} else {
|
||||
this.keyValueStore.setItem(this.popupKey, true);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -133,7 +133,9 @@
|
|||
{{plugin-outlet name="above-timeline" connectorTagName="div"}}
|
||||
|
||||
{{#topic-navigation class="topic-navigation" topic=model jumpToDate=(action "jumpToDate") jumpToIndex=(action "jumpToIndex") as |info|}}
|
||||
{{#unless site.mobileView}}
|
||||
{{plugin-outlet name="topic-navigation" connectorTagName="div" args=(hash topic=model)}}
|
||||
{{/unless}}
|
||||
|
||||
{{#if info.renderTimeline}}
|
||||
{{topic-timeline
|
||||
|
|
Loading…
Reference in New Issue