DEV: Fix `sidebar-hidden` localStorage value (#17915)
Previously ,`undefined` value for `sidebar-hidden` would mean "hide". Not it uses `true`. Also, extract it into a const.
This commit is contained in:
parent
afaa2d5417
commit
cac1608213
|
@ -4,22 +4,24 @@ import discourseDebounce from "discourse-common/lib/debounce";
|
||||||
import { inject as service } from "@ember/service";
|
import { inject as service } from "@ember/service";
|
||||||
import { action } from "@ember/object";
|
import { action } from "@ember/object";
|
||||||
|
|
||||||
|
const HIDE_SIDEBAR_KEY = "sidebar-hidden";
|
||||||
|
|
||||||
export default Controller.extend({
|
export default Controller.extend({
|
||||||
queryParams: ["enable_sidebar"],
|
queryParams: ["enable_sidebar"],
|
||||||
|
|
||||||
showTop: true,
|
showTop: true,
|
||||||
showFooter: false,
|
showFooter: false,
|
||||||
router: service(),
|
router: service(),
|
||||||
showSidebar: null,
|
showSidebar: false,
|
||||||
hideSidebarKey: "sidebar-hidden",
|
|
||||||
enable_sidebar: null,
|
enable_sidebar: null,
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
this.showSidebar = this.site.mobileView
|
this.showSidebar =
|
||||||
? false
|
this.currentUser &&
|
||||||
: this.currentUser && !this.keyValueStore.getItem(this.hideSidebarKey);
|
!this.site.mobileView &&
|
||||||
|
!this.keyValueStore.getItem(HIDE_SIDEBAR_KEY);
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed
|
@discourseComputed
|
||||||
|
@ -86,9 +88,9 @@ export default Controller.extend({
|
||||||
|
|
||||||
if (this.site.desktopView) {
|
if (this.site.desktopView) {
|
||||||
if (this.showSidebar) {
|
if (this.showSidebar) {
|
||||||
this.keyValueStore.removeItem(this.hideSidebarKey);
|
this.keyValueStore.removeItem(HIDE_SIDEBAR_KEY);
|
||||||
} else {
|
} else {
|
||||||
this.keyValueStore.setItem(this.hideSidebarKey);
|
this.keyValueStore.setItem(HIDE_SIDEBAR_KEY, "true");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue