FIX: use search message context on group message page (#13936)

FIX: use search message context on group message page (#13936)

diff --git a/app/assets/javascripts/discourse/app/routes/build-group-messages-route.js b/app/assets/javascripts/discourse/app/routes/build-group-messages-route.js
index 4de94e6..cf42669 100644
--- a/app/assets/javascripts/discourse/app/routes/build-group-messages-route.js
+++ b/app/assets/javascripts/discourse/app/routes/build-group-messages-route.js
@@ -31,10 +31,21 @@ export default (type) => {
         hideCategory: true,
         showPosters: true,
       });
+
+      const currentUser = this.currentUser;
+      this.searchService.set("searchContext", {
+        type: "private_messages",
+        id: currentUser.get("username_lower"),
+        user: currentUser,
+      });
     },
 
     _isArchive() {
       return type === "archive";
     },
+
+    deactivate() {
+      this.searchService.set("searchContext", null);
+    },
   });
 };
diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-test.js
index 7f1dbd5..9643261 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/group-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/group-test.js
@@ -241,6 +241,12 @@ acceptance("Group - Authenticated", function (needs) {
       "This is a private message 1",
       "it should display the list of group topics"
     );
+
+    await click("#search-button");
+    assert.ok(
+      exists(".search-context input:checked"),
+      "scope to message checkbox is checked"
+    );
   });
 
   test("Admin Viewing Group", async function (assert) {

GitHub sha: 4122affc0fb7dbd86b37562c2cf3462120550412

This commit appears in #13936 which was approved by tgxworld. It was merged by techAPJ.

This commit has been mentioned on Discourse Meta. There might be relevant details there: