Merge pull request #3773 from tgxworld/fix_composer_bug

FIX: Composer being abandoned when transiting between routes.
This commit is contained in:
Robin Ward 2015-09-16 14:34:46 -04:00
commit d61cfbe2aa
2 changed files with 17 additions and 14 deletions

View File

@ -457,8 +457,7 @@ export default Ember.Controller.extend({
// If we're already open, we don't have to do anything
if (composerModel.get('composeState') === Discourse.Composer.OPEN &&
composerModel.get('draftKey') === opts.draftKey &&
self._isComposerReply(composerModel, opts)) {
composerModel.get('draftKey') === opts.draftKey && !opts.action) {
return resolve();
}
@ -466,7 +465,7 @@ export default Ember.Controller.extend({
if (composerModel.get('composeState') === Discourse.Composer.DRAFT &&
composerModel.get('draftKey') === opts.draftKey) {
composerModel.set('composeState', Discourse.Composer.OPEN);
if (self._isComposerReply(composerModel, opts)) return resolve();
if (!opts.action) return resolve();
}
// If it's a different draft, cancel it and try opening again.
@ -489,11 +488,6 @@ export default Ember.Controller.extend({
});
},
_isComposerReply(composerModel, opts) {
return (composerModel.get('action') === Discourse.Composer.REPLY &&
composerModel.get('action') === opts.action);
},
// Given a potential instance and options, set the model for this composer.
_setModel(composerModel, opts) {
if (opts.draft) {

View File

@ -207,12 +207,21 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
return bootbox.alert(I18n.t('post.controls.edit_anonymous'));
}
this.get('controllers.composer').open({
const composer = this.get('controllers.composer'),
composerModel = composer.get('model'),
opts = {
post: post,
action: Discourse.Composer.EDIT,
draftKey: post.get('topic.draft_key'),
draftSequence: post.get('topic.draft_sequence')
});
};
// Cancel and reopen the composer for the first post
if (composerModel && (post.get('firstPost') || composerModel.get('editingPost'))) {
composer.cancelComposer().then(() => composer.open(opts));
} else {
composer.open(opts);
}
},
toggleBookmark(post) {