If the composer is already open with the same draft, we don't have to
close and reopen it.
This commit is contained in:
parent
897f219d61
commit
2e3842084c
|
@ -268,19 +268,26 @@ export default Discourse.Controller.extend({
|
||||||
|
|
||||||
return new Ember.RSVP.Promise(function(resolve, reject) {
|
return new Ember.RSVP.Promise(function(resolve, reject) {
|
||||||
if (composerModel && composerModel.get('replyDirty')) {
|
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 &&
|
if (composerModel.get('composeState') === Discourse.Composer.DRAFT &&
|
||||||
composerModel.get('draftKey') === opts.draftKey &&
|
composerModel.get('draftKey') === opts.draftKey &&
|
||||||
composerModel.action === opts.action) {
|
composerModel.action === opts.action) {
|
||||||
|
|
||||||
// If it's the same draft, just open it up again.
|
|
||||||
composerModel.set('composeState', Discourse.Composer.OPEN);
|
composerModel.set('composeState', Discourse.Composer.OPEN);
|
||||||
return resolve();
|
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
|
// we need a draft sequence for the composer to work
|
||||||
|
|
Loading…
Reference in New Issue