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.
This commit is contained in:
Bianca Nenciu 2021-09-17 03:37:36 +03:00 committed by GitHub
parent 7082e32122
commit 85fa1f90aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 6 deletions

View File

@ -91,16 +91,21 @@ function registerTopicFooterButtons(api) {
const taskActions = getOwner(this).lookup("service:task-actions"); const taskActions = getOwner(this).lookup("service:task-actions");
const topic = this.topic; 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); this.set("topic.assigned_to_user", null);
taskActions.unassign(topic.id);
} else if (topic.assigned_to_group) {
this.set("topic.assigned_to_group", null); 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 { } else {
taskActions.assign(topic); taskActions.assign(topic).set("model.onSuccess", () => {
this.appEvents.trigger("post-stream:refresh", {
id: topic.postStream.firstPostId,
});
});
} }
}, },
dropdown() { dropdown() {