FIX: update the list of users after user joined group (#13822)

FIX: update the list of users after user joined group (#13822)

  • Make UI update after user have joined a public group

  • Check if a group exists in the join method

diff --git a/app/assets/javascripts/discourse/app/models/group.js b/app/assets/javascripts/discourse/app/models/group.js
index 6ce97c8..b65f29e 100644
--- a/app/assets/javascripts/discourse/app/models/group.js
+++ b/app/assets/javascripts/discourse/app/models/group.js
@@ -131,7 +131,7 @@ const Group = RestModel.extend({
     return ajax(`/groups/${this.id}/join.json`, {
       type: "PUT",
     }).then(() => {
-      this.findMembers();
+      this.findMembers({}, true);
     });
   },
 
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index 4db8e7b..fd09ecb 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -398,6 +398,7 @@ class GroupsController < ApplicationController
     end
 
     group = Group.find(params[:id])
+    raise Discourse::NotFound unless group
     raise Discourse::InvalidAccess unless group.public_admission
 
     return if group.users.exists?(id: current_user.id)

GitHub sha: 73e8183ffb8fe5587650ee097837fe5eaeed6441

This commit appears in #13822 which was approved by ZogStriP. It was merged by AndrewPrigorshnev.