FIX: Make 'group membership requests' feature compatible with visibility level option 'logged_on_users'.

FIX: Make ‘group membership requests’ feature compatible with visibility level option ‘logged_on_users’.

diff --git a/app/assets/javascripts/discourse/components/groups-form-membership-fields.js.es6 b/app/assets/javascripts/discourse/components/groups-form-membership-fields.js.es6
index 306f9a0..6cf923d 100644
--- a/app/assets/javascripts/discourse/components/groups-form-membership-fields.js.es6
+++ b/app/assets/javascripts/discourse/components/groups-form-membership-fields.js.es6
@@ -19,12 +19,12 @@ export default Ember.Component.extend({
   @computed("model.visibility_level", "model.public_admission")
   disableMembershipRequestSetting(visibility_level, publicAdmission) {
     visibility_level = parseInt(visibility_level);
-    return visibility_level !== 0 || publicAdmission;
+    return ![0, 1].includes(visibility_level) || publicAdmission;
   },
 
   @computed("model.visibility_level", "model.allow_membership_requests")
   disablePublicSetting(visibility_level, allowMembershipRequests) {
     visibility_level = parseInt(visibility_level);
-    return visibility_level !== 0 || allowMembershipRequests;
+    return ![0, 1].includes(visibility_level) || allowMembershipRequests;
   }
 });
diff --git a/app/assets/javascripts/discourse/models/group.js.es6 b/app/assets/javascripts/discourse/models/group.js.es6
index 0489835..383c468 100644
--- a/app/assets/javascripts/discourse/models/group.js.es6
+++ b/app/assets/javascripts/discourse/models/group.js.es6
@@ -139,7 +139,7 @@ const Group = RestModel.extend({
 
   @computed("visibility_level")
   isPrivate(visibilityLevel) {
-    return visibilityLevel !== 0;
+    return ![0, 1].includes(visibilityLevel);
   },
 
   @observes("isPrivate", "canEveryoneMention")
@@ -149,13 +149,6 @@ const Group = RestModel.extend({
     }
   },
 
-  @observes("visibility_level")
-  _updatePublic() {
-    if (this.isPrivate) {
-      this.setProperties({ public: false, allow_membership_requests: false });
-    }
-  },
-
   asJSON() {
     const attrs = {
       name: this.name,

GitHub sha: 82c5a1d2

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

thanks, I’ll update my install and report

Why not do this instead?

return publicAdmission || visibility_level < 1;
1 Like

DEV: improve the code readability.

Yes, it’s easy to read. Not sure about why mind came up with the above idea :stuck_out_tongue_winking_eye: DEV: improve the code readability. · discourse/discourse@c1769b0 · GitHub

1 Like