mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-29 22:01:49 +03:00
e01ffa3620
no issue - review use of Ember core hooks and add a call to `this._super` if missing - fix a few occurrences of using the wrong component lifecycle hooks that could result in multiple/duplicate event handlers being attached `_super` should always be called when overriding Ember's base hooks so that core functionality or app functionality added through extensions, mixins or addons is not lost. This is important as it guards against issues arising from later refactorings or core changes. As example of lost functionality, there were a number of routes that extended from `AuthenticatedRoute` but then overrode the `beforeModel` hook without calling `_super` which meant that the route was no longer treated as authenticated.
52 lines
1.4 KiB
JavaScript
52 lines
1.4 KiB
JavaScript
import AuthenticatedRoute from 'ghost/routes/authenticated';
|
|
import base from 'ghost/mixins/editor-base-route';
|
|
|
|
export default AuthenticatedRoute.extend(base, {
|
|
titleToken: 'Editor',
|
|
|
|
model() {
|
|
return this.get('session.user').then((user) => {
|
|
return this.store.createRecord('post', {
|
|
author: user
|
|
});
|
|
});
|
|
},
|
|
|
|
renderTemplate(controller, model) {
|
|
this.render('editor/edit', {
|
|
controller,
|
|
model
|
|
});
|
|
|
|
this.render('post-settings-menu', {
|
|
model,
|
|
into: 'application',
|
|
outlet: 'settings-menu'
|
|
});
|
|
},
|
|
|
|
setupController() {
|
|
let psm = this.controllerFor('post-settings-menu');
|
|
|
|
// make sure there are no titleObserver functions hanging around
|
|
// from previous posts
|
|
psm.removeObserver('titleScratch', psm, 'titleObserver');
|
|
|
|
// Ensure that the PSM Image Uploader and Publish Date selector resets
|
|
psm.send('resetUploader');
|
|
psm.send('resetPubDate');
|
|
|
|
this._super(...arguments);
|
|
},
|
|
|
|
actions: {
|
|
willTransition(transition) {
|
|
// decorate the transition object so the editor.edit route
|
|
// knows this was the previous active route
|
|
transition.data.fromNew = true;
|
|
|
|
this._super(...arguments);
|
|
}
|
|
}
|
|
});
|