mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 07:09:48 +03:00
a63dbb7da6
closes TryGhost/Ghost#8307 - unloading the store and refreshing the `session.user` attribute after an import was triggering a rendering edge case where the style was re-computed and a re-render was attempted after the sidebar has been destroyed - rather than binding a style attribute directly to a CP in `gh-nav-menu` we pass the menu icon in (using `settings.settledIcon` - see below) and manually set the style attribute via the `didReceiveAttrs` hook so that outside changes don't trigger re-computations when we don't expect them and so we can still react to icons being uploaded or removed - our usage of `settings.icon` is a bit of an odd situation because it's a link to an external resource that will only resolve correctly after a successful save - if we change `settings.icon` in the local store and the nav menu icon style updates before the save has been completed then the server will give us the old icon. To work around this a `settings.settledIcon` attribute has been added that is only updated when we receive data from the store ensuring that our cache-busting technique works correctly
64 lines
1.8 KiB
JavaScript
64 lines
1.8 KiB
JavaScript
import Controller from 'ember-controller';
|
|
import computed from 'ember-computed';
|
|
import injectService from 'ember-service/inject';
|
|
|
|
export default Controller.extend({
|
|
dropdown: injectService(),
|
|
session: injectService(),
|
|
settings: injectService(),
|
|
|
|
showNavMenu: computed('currentPath', 'session.isAuthenticated', 'session.user.isFulfilled', function () {
|
|
// we need to defer showing the navigation menu until the session.user
|
|
// promise has fulfilled so that gh-user-can-admin has the correct data
|
|
if (!this.get('session.isAuthenticated') || !this.get('session.user.isFulfilled')) {
|
|
return false;
|
|
}
|
|
|
|
return (this.get('currentPath') !== 'error404' || this.get('session.isAuthenticated'))
|
|
&& !this.get('currentPath').match(/(signin|signup|setup|reset)/);
|
|
}),
|
|
|
|
topNotificationCount: 0,
|
|
showMobileMenu: false,
|
|
showSettingsMenu: false,
|
|
showMarkdownHelpModal: false,
|
|
|
|
autoNav: false,
|
|
autoNavOpen: computed('autoNav', {
|
|
get() {
|
|
return false;
|
|
},
|
|
set(key, value) {
|
|
if (this.get('autoNav')) {
|
|
return value;
|
|
}
|
|
return false;
|
|
}
|
|
}),
|
|
|
|
actions: {
|
|
topNotificationChange(count) {
|
|
this.set('topNotificationCount', count);
|
|
},
|
|
|
|
toggleAutoNav() {
|
|
this.toggleProperty('autoNav');
|
|
},
|
|
|
|
openAutoNav() {
|
|
this.set('autoNavOpen', true);
|
|
},
|
|
|
|
closeAutoNav() {
|
|
if (this.get('autoNavOpen')) {
|
|
this.get('dropdown').closeDropdowns();
|
|
}
|
|
this.set('autoNavOpen', false);
|
|
},
|
|
|
|
closeMobileMenu() {
|
|
this.set('showMobileMenu', false);
|
|
}
|
|
}
|
|
});
|