If the composer is already open with the same draft, we don't have to

close and reopen it.
This commit is contained in:
Robin Ward 2014-06-04 14:46:03 -04:00
parent 897f219d61
commit 2e3842084c

View File

@ -268,19 +268,26 @@ export default Discourse.Controller.extend({
return new Ember.RSVP.Promise(function(resolve, reject) {
if (composerModel && composerModel.get('replyDirty')) {
// If we're already open, we don't have to do anything
if (composerModel.get('composeState') === Discourse.Composer.OPEN &&
composerModel.get('draftKey') === opts.draftKey) {
return resolve();
}
// If it's the same draft, just open it up again.
if (composerModel.get('composeState') === Discourse.Composer.DRAFT &&
composerModel.get('draftKey') === opts.draftKey &&
composerModel.action === opts.action) {
// If it's the same draft, just open it up again.
composerModel.set('composeState', Discourse.Composer.OPEN);
return resolve();
} else {
// If it's a different draft, cancel it and try opening again.
return self.cancelComposer().then(function() {
return self.open(opts);
}).then(resolve, reject);
}
// If it's a different draft, cancel it and try opening again.
return self.cancelComposer().then(function() {
return self.open(opts);
}).then(resolve, reject);
}
// we need a draft sequence for the composer to work