PERF: stop destroying drafts on client when posting replies

The server already ensures it advances draft keys when a post is created
this means this code that used to delete drafts is simply introducing
composer delays with no benefit.
This commit is contained in:
Sam Saffron 2019-10-29 17:07:33 +11:00
parent b92e4465f7
commit 492742837e
1 changed files with 22 additions and 36 deletions

View File

@ -687,16 +687,6 @@ export default Controller.extend({
}); });
} }
// If user "created a new topic/post" or "replied as a new topic" successfully, remove the draft.
let destroyDraftPromise;
if (result.responseJson.action === "create_post") {
destroyDraftPromise = this.destroyDraft();
} else {
destroyDraftPromise = Ember.RSVP.Promise.resolve();
}
return destroyDraftPromise.then(() => {
if (this.get("model.editingPost")) { if (this.get("model.editingPost")) {
this.appEvents.trigger("post-stream:refresh", { this.appEvents.trigger("post-stream:refresh", {
id: parseInt(result.responseJson.id) id: parseInt(result.responseJson.id)
@ -709,10 +699,7 @@ export default Controller.extend({
} }
if (result.responseJson.action === "create_post") { if (result.responseJson.action === "create_post") {
this.appEvents.trigger( this.appEvents.trigger("post:highlight", result.payload.post_number);
"post:highlight",
result.payload.post_number
);
} }
this.close(); this.close();
@ -727,7 +714,6 @@ export default Controller.extend({
if (post && !staged) { if (post && !staged) {
DiscourseURL.routeTo(post.url); DiscourseURL.routeTo(post.url);
} }
});
}) })
.catch(error => { .catch(error => {
composer.set("disableDrafts", false); composer.set("disableDrafts", false);