FIX: correctly update UI when post is assigned/unassigned (#233)

Update topic title, first post and related post
This commit is contained in:
Krzysztof Kotlarek 2021-11-09 08:40:43 +11:00 committed by GitHub
parent 2d1f5668a5
commit 69dac06a82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -180,7 +180,11 @@ function initialize(api) {
}); });
api.attachWidgetAction("post", "unassignPost", function () { api.attachWidgetAction("post", "unassignPost", function () {
const taskActions = getOwner(this).lookup("service:task-actions"); const taskActions = getOwner(this).lookup("service:task-actions");
taskActions.unassign(this.model.id, "Post"); taskActions.unassign(this.model.id, "Post").then(() => {
delete this.model.topic.indirectly_assigned_to[
this.model.post_number
];
});
}); });
} }
} }
@ -450,8 +454,11 @@ function initialize(api) {
if (data.post_id) { if (data.post_id) {
if (data.type === "unassigned") { if (data.type === "unassigned") {
delete topic.indirectly_assigned_to[data.post_id]; delete topic.indirectly_assigned_to[data.post_number];
} }
this.appEvents.trigger("post-stream:refresh", {
id: topic.postStream.posts[0].id,
});
this.appEvents.trigger("post-stream:refresh", { id: data.post_id }); this.appEvents.trigger("post-stream:refresh", { id: data.post_id });
} }
} }

View File

@ -222,6 +222,7 @@ class ::Assigner
type: "assigned", type: "assigned",
topic_id: topic.id, topic_id: topic.id,
post_id: post_target? && @target.id, post_id: post_target? && @target.id,
post_number: post_target? && @target.post_number,
assigned_type: type, assigned_type: type,
assigned_to: serializer.new(assign_to, scope: Guardian.new, root: false).as_json assigned_to: serializer.new(assign_to, scope: Guardian.new, root: false).as_json
}, },
@ -375,6 +376,7 @@ class ::Assigner
type: 'unassigned', type: 'unassigned',
topic_id: topic.id, topic_id: topic.id,
post_id: post_target? && @target.id, post_id: post_target? && @target.id,
post_number: post_target? && @target.post_number,
assigned_type: assignment.assigned_to.is_a?(User) ? "User" : "Group" assigned_type: assignment.assigned_to.is_a?(User) ? "User" : "Group"
}, },
user_ids: allowed_user_ids user_ids: allowed_user_ids