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
This commit is contained in:
Sam Saffron 2020-04-01 14:23:26 +11:00
parent 04b431b6a4
commit b8d2261db9
No known key found for this signature in database
GPG Key ID: B9606168D2FFD9F5
3 changed files with 17 additions and 14 deletions

View File

@ -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);

View File

@ -9,6 +9,8 @@
closeComposer=closeComposer
action=model.action
tabindex=tabindex
topic=model.topic
post=model.post
}}
{{/if}}

View File

@ -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();
}