FIX: Reload messages after a bulk operation (#12569)

FIX: Reload messages after a bulk operation (#12569)

It did not show the updated state of the topic until user refreshed the page.

diff --git a/app/assets/javascripts/discourse/app/controllers/topic-bulk-actions.js b/app/assets/javascripts/discourse/app/controllers/topic-bulk-actions.js
index 1b77365..eaed7ff 100644
--- a/app/assets/javascripts/discourse/app/controllers/topic-bulk-actions.js
+++ b/app/assets/javascripts/discourse/app/controllers/topic-bulk-actions.js
@@ -253,7 +253,7 @@ export default Controller.extend(ModalFunctionality, {
       if (this.isGroup) {
         params.group = this.groupFilter;
       }
-      this.forEachPerformed(params, (t) => t.set("archived", true));
+      this.performAndRefresh(params);
     },
 
     moveMessagesToInbox() {
@@ -261,7 +261,7 @@ export default Controller.extend(ModalFunctionality, {
       if (this.isGroup) {
         params.group = this.groupFilter;
       }
-      this.forEachPerformed(params, (t) => t.set("archived", false));
+      this.performAndRefresh(params);
     },
 
     unlistTopics() {
diff --git a/app/assets/javascripts/discourse/app/controllers/user-private-messages.js b/app/assets/javascripts/discourse/app/controllers/user-private-messages.js
index 4e12e56..222b819 100644
--- a/app/assets/javascripts/discourse/app/controllers/user-private-messages.js
+++ b/app/assets/javascripts/discourse/app/controllers/user-private-messages.js
@@ -55,6 +55,7 @@ export default Controller.extend({
 
   @action
   toggleBulkSelect() {
+    this.selected.clear();
     this.toggleProperty("bulkSelectEnabled");
   },
 });
diff --git a/app/assets/javascripts/discourse/app/routes/user-private-messages.js b/app/assets/javascripts/discourse/app/routes/user-private-messages.js
index 4985142..bedaa51 100644
--- a/app/assets/javascripts/discourse/app/routes/user-private-messages.js
+++ b/app/assets/javascripts/discourse/app/routes/user-private-messages.js
@@ -29,6 +29,10 @@ export default DiscourseRoute.extend({
   },
 
   actions: {
+    refresh() {
+      this.refresh();
+    },
+
     willTransition: function () {
       this._super(...arguments);
       this.controllerFor("user").set("pmView", null);
diff --git a/app/assets/javascripts/discourse/app/templates/user/messages.hbs b/app/assets/javascripts/discourse/app/templates/user/messages.hbs
index 3c49419..004b58b 100644
--- a/app/assets/javascripts/discourse/app/templates/user/messages.hbs
+++ b/app/assets/javascripts/discourse/app/templates/user/messages.hbs
@@ -60,7 +60,7 @@
     {{#unless site.mobileView}}
       {{#if showToggleBulkSelect}}
         {{d-button icon="list" class="btn-default bulk-select" title="topics.bulk.toggle" action=(action "toggleBulkSelect")}}
-        {{bulk-select-button selected=selected}}
+        {{bulk-select-button selected=selected action=(route-action "refresh")}}
       {{/if}}
     {{/unless}}
 

GitHub sha: 27b29747

This commit appears in #12569 which was approved by ZogStriP. It was merged by nbianca.