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:
Bianca Nenciu 2022-01-19 16:20:05 +02:00 committed by GitHub
parent 376799b1a4
commit 4951900bbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 1 deletions

View File

@ -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);
}
}
},
});

View File

@ -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