FIX: correctly load drafts based of id
Previously we relied on race conditions to correctly open a draft, so this broke.
New code is deliberate.
Also corrects missing observers on composer action
diff --git a/app/assets/javascripts/discourse/models/composer.js b/app/assets/javascripts/discourse/models/composer.js
index 9d0dcb8..1b1fd0a 100644
--- a/app/assets/javascripts/discourse/models/composer.js
+++ b/app/assets/javascripts/discourse/models/composer.js
@@ -744,9 +744,12 @@ const Composer = RestModel.extend({
if (opts.postId) {
promise = promise.then(() =>
- this.store
- .find("post", opts.postId)
- .then(post => composer.setProperties({ post }))
+ this.store.find("post", opts.postId).then(post => {
+ composer.set("post", post);
+ if (post) {
+ composer.set("topic", post.topic);
+ }
+ })
);
}
@@ -765,7 +768,9 @@ const Composer = RestModel.extend({
this.store.find("post", opts.post.id).then(post => {
composer.setProperties({
reply: post.raw,
- originalText: post.raw
+ originalText: post.raw,
+ post: post,
+ topic: post.topic
});
composer.appEvents.trigger("composer:reply-reloaded", composer);
diff --git a/app/assets/javascripts/discourse/templates/components/composer-action-title.hbs b/app/assets/javascripts/discourse/templates/components/composer-action-title.hbs
index 3f26b6e..5d3b2ee 100644
--- a/app/assets/javascripts/discourse/templates/components/composer-action-title.hbs
+++ b/app/assets/javascripts/discourse/templates/components/composer-action-title.hbs
@@ -9,6 +9,8 @@
closeComposer=closeComposer
action=model.action
tabindex=tabindex
+ topic=model.topic
+ post=model.post
}}
{{/if}}
diff --git a/app/assets/javascripts/select-kit/components/composer-actions.js b/app/assets/javascripts/select-kit/components/composer-actions.js
index 720dddd..548a0ef 100644
--- a/app/assets/javascripts/select-kit/components/composer-actions.js
+++ b/app/assets/javascripts/select-kit/components/composer-actions.js
@@ -39,21 +39,17 @@ export default DropdownSelectBoxComponent.extend({
// if we change topic we want to change both snapshots
if (
- this.get("composerModel.topic") &&
- (!_topicSnapshot ||
- this.get("composerModel.topic.id") !== _topicSnapshot.id)
+ this.topic &&
+ (!_topicSnapshot || this.topic.id !== _topicSnapshot.id)
) {
- _topicSnapshot = this.get("composerModel.topic");
- _postSnapshot = this.get("composerModel.post");
+ _topicSnapshot = this.topic;
+ _postSnapshot = this.post;
this.contentChanged();
}
// if we hit reply on a different post we want to change postSnapshot
- if (
- this.get("composerModel.post") &&
- (!_postSnapshot || this.get("composerModel.post.id") !== _postSnapshot.id)
- ) {
- _postSnapshot = this.get("composerModel.post");
+ if (this.post && (!_postSnapshot || this.post.id !== _postSnapshot.id)) {
+ _postSnapshot = this.post;
this.contentChanged();
}
GitHub sha: b8d2261d