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:
parent
04b431b6a4
commit
b8d2261db9
|
@ -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);
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
closeComposer=closeComposer
|
||||
action=model.action
|
||||
tabindex=tabindex
|
||||
topic=model.topic
|
||||
post=model.post
|
||||
}}
|
||||
{{/if}}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue