diff --git a/app/assets/javascripts/discourse/controllers/composer_controller.js b/app/assets/javascripts/discourse/controllers/composer_controller.js index 2ecbe46b255..1f32fb28a5b 100644 --- a/app/assets/javascripts/discourse/controllers/composer_controller.js +++ b/app/assets/javascripts/discourse/controllers/composer_controller.js @@ -333,14 +333,14 @@ Discourse.ComposerController = Discourse.Controller.extend({ cancelComposer: function() { var self = this; - return Ember.Deferred.promise(function (promise) { + return new Ember.RSVP.Promise(function (resolve) { if (self.get('model.hasMetaData') || self.get('model.replyDirty')) { bootbox.confirm(I18n.t("post.abandon"), I18n.t("no_value"), I18n.t("yes_value"), function(result) { if (result) { self.destroyDraft(); self.get('model').clearState(); self.close(); - promise.resolve(); + resolve(); } }); } else { @@ -348,7 +348,7 @@ Discourse.ComposerController = Discourse.Controller.extend({ self.destroyDraft(); self.get('model').clearState(); self.close(); - promise.resolve(); + resolve(); } }); }, diff --git a/app/assets/javascripts/discourse/routes/discovery_route.js b/app/assets/javascripts/discourse/routes/discovery_route.js index d83f0378e18..9ed230f969e 100644 --- a/app/assets/javascripts/discourse/routes/discovery_route.js +++ b/app/assets/javascripts/discourse/routes/discovery_route.js @@ -31,7 +31,6 @@ Discourse.DiscoveryRoute = Discourse.Route.extend({ this.controllerFor('composer').open({ categoryId: topicsController.get('category.id'), action: Discourse.Composer.CREATE_TOPIC, - draft: topicsController.get('draft'), draftKey: topicsController.get('draft_key'), draftSequence: topicsController.get('draft_sequence') }); diff --git a/app/assets/javascripts/discourse/routes/discovery_route_builders.js b/app/assets/javascripts/discourse/routes/discovery_route_builders.js index c9f75994d23..0ec08b890b4 100644 --- a/app/assets/javascripts/discourse/routes/discovery_route_builders.js +++ b/app/assets/javascripts/discourse/routes/discovery_route_builders.js @@ -28,6 +28,17 @@ function buildTopicRoute(filter) { Discourse.set('title', I18n.t('filters.with_topics', {filter: filterText})); this.controllerFor('discoveryTopics').setProperties({ model: model, category: null, period: period }); + + // If there's a draft, open the create topic composer + if (model.draft) { + this.controllerFor('composer').open({ + action: Discourse.Composer.CREATE_TOPIC, + draft: model.draft, + draftKey: model.draft_key, + draftSequence: model.draft_sequence + }); + } + this.controllerFor('navigationDefault').set('canCreateTopic', model.get('can_create_topic')); },