FIX: use 'about.json' endpoint instead of using ember model to get the data.

FIX: use ‘about.json’ endpoint instead of using ember model to get the data.

diff --git a/app/assets/javascripts/admin/mixins/setting-component.js.es6 b/app/assets/javascripts/admin/mixins/setting-component.js.es6
index eaf5b356b6..bd73175899 100644
--- a/app/assets/javascripts/admin/mixins/setting-component.js.es6
+++ b/app/assets/javascripts/admin/mixins/setting-component.js.es6
@@ -4,8 +4,8 @@ import { categoryLinkHTML } from "discourse/helpers/category-link";
 import { on } from "@ember/object/evented";
 import Mixin from "@ember/object/mixin";
 import showModal from "discourse/lib/show-modal";
-import AboutRoute from "discourse/routes/about";
 import { Promise } from "rsvp";
+import { ajax } from "discourse/lib/ajax";
 
 const CUSTOM_TYPES = [
   "bool",
@@ -151,22 +151,20 @@ export default Mixin.create({
       const key = this.buffered.get("setting");
 
       if (defaultUserPreferences.includes(key)) {
-        AboutRoute.create()
-          .model()
-          .then(result => {
-            const controller = showModal("site-setting-default-categories", {
-              model: {
-                count: result.stats.user_count,
-                key: key.replace(/_/g, " ")
-              },
-              admin: true
-            });
-
-            controller.set("onClose", () => {
-              this.updateExistingUsers = controller.updateExistingUsers;
-              this.send("save");
-            });
+        ajax("/about.json").then(result => {
+          const controller = showModal("site-setting-default-categories", {
+            model: {
+              count: result.about.stats.user_count,
+              key: key.replace(/_/g, " ")
+            },
+            admin: true
           });
+
+          controller.set("onClose", () => {
+            this.updateExistingUsers = controller.updateExistingUsers;
+            this.send("save");
+          });
+        });
       } else {
         this.send("save");
       }

GitHub sha: edec9228

Why do we need to use the about.json endpoint?

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

To get the total number of users. Anyway, I’m going to change the behavior here. Instead of displaying the total number of users on the site I will display the total number of users going to be affected by the site setting change.

2 Likes