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

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

Update topic title, first post and related post

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 c99d567..c3f34ab 100644
--- a/assets/javascripts/discourse-assign/initializers/extend-for-assigns.js.es6
+++ b/assets/javascripts/discourse-assign/initializers/extend-for-assigns.js.es6
@@ -180,7 +180,11 @@ function initialize(api) {
       });
       api.attachWidgetAction("post", "unassignPost", function () {
         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.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 });
           }
         }
diff --git a/lib/assigner.rb b/lib/assigner.rb
index 0cb774c..8f81521 100644
--- a/lib/assigner.rb
+++ b/lib/assigner.rb
@@ -222,6 +222,7 @@ class ::Assigner
         type: "assigned",
         topic_id: topic.id,
         post_id: post_target? && @target.id,
+        post_number: post_target? && @target.post_number,
         assigned_type: type,
         assigned_to: serializer.new(assign_to, scope: Guardian.new, root: false).as_json
       },
@@ -375,6 +376,7 @@ class ::Assigner
           type: 'unassigned',
           topic_id: topic.id,
           post_id: post_target? && @target.id,
+          post_number: post_target? && @target.post_number,
           assigned_type: assignment.assigned_to.is_a?(User) ? "User" : "Group"
         },
         user_ids: allowed_user_ids

GitHub sha: 69dac06a82a4fa812659459c8b3c650f5497de68

This commit appears in #233 which was approved by eviltrout. It was merged by lis2.