From 85fa1f90aab576f399d8d346b233d2265e42f185 Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Fri, 17 Sep 2021 03:37:36 +0300 Subject: [PATCH] FIX: Refresh first post after assign and unassign (#212) The first post showed the assign status when it was loaded and did not update if it changed. The page had to be refreshed for the text to be updated. --- .../initializers/extend-for-assigns.js.es6 | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/assets/javascripts/discourse-assign/initializers/extend-for-assigns.js.es6 b/assets/javascripts/discourse-assign/initializers/extend-for-assigns.js.es6 index 3183d33..ae00c4d 100644 --- a/assets/javascripts/discourse-assign/initializers/extend-for-assigns.js.es6 +++ b/assets/javascripts/discourse-assign/initializers/extend-for-assigns.js.es6 @@ -91,16 +91,21 @@ function registerTopicFooterButtons(api) { const taskActions = getOwner(this).lookup("service:task-actions"); const topic = this.topic; - const assignedUser = topic.get("assigned_to_user.username"); - if (assignedUser) { + if (topic.assigned_to_user || topic.assigned_to_group) { this.set("topic.assigned_to_user", null); - taskActions.unassign(topic.id); - } else if (topic.assigned_to_group) { this.set("topic.assigned_to_group", null); - taskActions.unassign(topic.id); + taskActions.unassign(topic.id).then(() => { + this.appEvents.trigger("post-stream:refresh", { + id: topic.postStream.firstPostId, + }); + }); } else { - taskActions.assign(topic); + taskActions.assign(topic).set("model.onSuccess", () => { + this.appEvents.trigger("post-stream:refresh", { + id: topic.postStream.firstPostId, + }); + }); } }, dropdown() {