PERF: Revert all inboxes from messages route. (#14445)

PERF: Revert all inboxes from messages route. (#14445)

The all inboxes was introduced in 016efeadf6f242e04daf5ef8e18c2ca708a1392d but we decided to roll it back for performance reasons. The main performance challenge here is that PG has to basically loop through all the PMs that a user is allowed to view before being able to order by Topic#bumped_at. The all inboxes was not planned as part of the new/unread filter so we’ve decided not to tackle the performance issue for the upcoming release.

Follow-up to 016efeadf6f242e04daf5ef8e18c2ca708a1392d

diff --git a/app/assets/javascripts/discourse/app/controllers/topic.js b/app/assets/javascripts/discourse/app/controllers/topic.js
index 8f83a5e..97ff99b 100644
--- a/app/assets/javascripts/discourse/app/controllers/topic.js
+++ b/app/assets/javascripts/discourse/app/controllers/topic.js
@@ -158,8 +158,6 @@ export default Controller.extend(bufferedProperty("model"), {
 
     if (name) {
       url = `${url}/group/${name}`;
-    } else {
-      url = `${url}/personal`;
     }
 
     DiscourseURL.routeTo(url);
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 2ff2c1f..b6e1f9a 100644
--- a/app/assets/javascripts/discourse/app/controllers/user-private-messages.js
+++ b/app/assets/javascripts/discourse/app/controllers/user-private-messages.js
@@ -6,7 +6,6 @@ import { VIEW_NAME_WARNINGS } from "discourse/routes/user-private-messages-warni
 import I18n from "I18n";
 
 export const PERSONAL_INBOX = "__personal_inbox__";
-const ALL_INBOX = "__all_inbox__";
 
 export default Controller.extend({
   user: controller(),
@@ -22,56 +21,17 @@ export default Controller.extend({
 
   showNewPM: and("user.viewingSelf", "currentUser.can_send_private_messages"),
 
-  @discourseComputed("inboxes", "isAllInbox")
-  displayGlobalFilters(inboxes, isAllInbox) {
-    if (inboxes.length === 0) {
-      return true;
-    }
-    if (inboxes.length && isAllInbox) {
-      return true;
-    }
-    return false;
-  },
-
-  @discourseComputed("inboxes")
-  sectionClass(inboxes) {
-    const defaultClass = "user-secondary-navigation user-messages";
-
-    return inboxes.length
-      ? `${defaultClass} user-messages-inboxes`
-      : defaultClass;
-  },
-
-  @discourseComputed("pmView")
-  isPersonalInbox(pmView) {
-    return pmView && pmView.startsWith("user");
-  },
-
-  @discourseComputed("isPersonalInbox", "group.name")
-  isAllInbox(isPersonalInbox, groupName) {
-    return !this.isPersonalInbox && !groupName;
-  },
-
-  @discourseComputed("isPersonalInbox", "group.name")
-  selectedInbox(isPersonalInbox, groupName) {
-    if (groupName) {
-      return groupName;
-    }
-
-    return isPersonalInbox ? PERSONAL_INBOX : ALL_INBOX;
-  },
-
   @discourseComputed("viewingSelf", "pmView", "currentUser.admin")
   showWarningsWarning(viewingSelf, pmView, isAdmin) {
     return pmView === VIEW_NAME_WARNINGS && !viewingSelf && !isAdmin;
   },
 
-  @discourseComputed("pmTopicTrackingState.newIncoming.[]", "selectedInbox")
+  @discourseComputed("pmTopicTrackingState.newIncoming.[]", "group")
   newLinkText() {
     return this._linkText("new");
   },
 
-  @discourseComputed("selectedInbox", "pmTopicTrackingState.newIncoming.[]")
+  @discourseComputed("pmTopicTrackingState.newIncoming.[]", "group")
   unreadLinkText() {
     return this._linkText("unread");
   },
@@ -86,45 +46,8 @@ export default Controller.extend({
     }
   },
 
-  @discourseComputed("model.groupsWithMessages")
-  inboxes(groupsWithMessages) {
-    if (!groupsWithMessages || groupsWithMessages.length === 0) {
-      return [];
-    }
-
-    const inboxes = [];
-
-    inboxes.push({
-      id: ALL_INBOX,
-      name: I18n.t("user.messages.all"),
-    });
-
-    inboxes.push({
-      id: PERSONAL_INBOX,
-      name: I18n.t("user.messages.personal"),
-      icon: "envelope",
-    });
-
-    groupsWithMessages.forEach((group) => {
-      inboxes.push({ id: group.name, name: group.name, icon: "users" });
-    });
-
-    return inboxes;
-  },
-
   @action
   changeGroupNotificationLevel(notificationLevel) {
     this.group.setNotification(notificationLevel, this.get("user.model.id"));
   },
-
-  @action
-  updateInbox(inbox) {
-    if (inbox === ALL_INBOX) {
-      this.transitionToRoute("userPrivateMessages.index");
-    } else if (inbox === PERSONAL_INBOX) {
-      this.transitionToRoute("userPrivateMessages.personal");
-    } else {
-      this.transitionToRoute("userPrivateMessages.group", inbox);
-    }
-  },
 });
diff --git a/app/assets/javascripts/discourse/app/routes/app-route-map.js b/app/assets/javascripts/discourse/app/routes/app-route-map.js
index 42eb98b..b4c778f 100644
--- a/app/assets/javascripts/discourse/app/routes/app-route-map.js
+++ b/app/assets/javascripts/discourse/app/routes/app-route-map.js
@@ -144,11 +144,6 @@ export default function () {
           this.route("unread");
           this.route("archive");
           this.route("sent");
-          this.route("personal");
-          this.route("personalSent", { path: "personal/sent" });
-          this.route("personalNew", { path: "personal/new" });
-          this.route("personalUnread", { path: "personal/unread" });
-          this.route("personalArchive", { path: "personal/archive" });
           this.route("warnings");
           this.route("group", { path: "group/:name" });
           this.route("groupArchive", { path: "group/:name/archive" });
diff --git a/app/assets/javascripts/discourse/app/routes/user-private-messages-archive.js b/app/assets/javascripts/discourse/app/routes/user-private-messages-archive.js
index 9861501..a612884 100644
--- a/app/assets/javascripts/discourse/app/routes/user-private-messages-archive.js
+++ b/app/assets/javascripts/discourse/app/routes/user-private-messages-archive.js
@@ -3,7 +3,7 @@ import createPMRoute, {
 } from "discourse/routes/build-private-messages-route";
 
 export default createPMRoute(
-  "all",
-  "private-messages-all-archive",
+  "user",
+  "private-messages-archive",
   ARCHIVE_FILTER
 );
diff --git a/app/assets/javascripts/discourse/app/routes/user-private-messages-index.js b/app/assets/javascripts/discourse/app/routes/user-private-messages-index.js
index aab9f5a..fd0a1f8 100644
--- a/app/assets/javascripts/discourse/app/routes/user-private-messages-index.js
+++ b/app/assets/javascripts/discourse/app/routes/user-private-messages-index.js
@@ -2,4 +2,4 @@ import createPMRoute, {
   INBOX_FILTER,
 } from "discourse/routes/build-private-messages-route";
 
-export default createPMRoute("all", "private-messages-all", INBOX_FILTER);
+export default createPMRoute("user", "private-messages", INBOX_FILTER);
diff --git a/app/assets/javascripts/discourse/app/routes/user-private-messages-new.js b/app/assets/javascripts/discourse/app/routes/user-private-messages-new.js
index cb064b2..5e0ab10 100644
--- a/app/assets/javascripts/discourse/app/routes/user-private-messages-new.js
+++ b/app/assets/javascripts/discourse/app/routes/user-private-messages-new.js
@@ -3,4 +3,4 @@ import {
   default as createPMRoute,
 } from "discourse/routes/build-private-messages-route";
 
-export default createPMRoute("all", "private-messages-all-new", NEW_FILTER);
+export default createPMRoute("user", "private-messages-new", NEW_FILTER);
diff --git a/app/assets/javascripts/discourse/app/routes/user-private-messages-personal-archive.js b/app/assets/javascripts/discourse/app/routes/user-private-messages-personal-archive.js
deleted file mode 100644
index a612884..0000000
--- a/app/assets/javascripts/discourse/app/routes/user-private-messages-personal-archive.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import createPMRoute, {
-  ARCHIVE_FILTER,
-} from "discourse/routes/build-private-messages-route";
-
-export default createPMRoute(
-  "user",
-  "private-messages-archive",
-  ARCHIVE_FILTER
-);
diff --git a/app/assets/javascripts/discourse/app/routes/user-private-messages-personal-new.js b/app/assets/javascripts/discourse/app/routes/user-private-messages-personal-new.js
deleted file mode 100644
index 5e0ab10..0000000
--- a/app/assets/javascripts/discourse/app/routes/user-private-messages-personal-new.js
+++ /dev/null
@@ -1,6 +0,0 @@
-import {
-  NEW_FILTER,
-  default as createPMRoute,
-} from "discourse/routes/build-private-messages-route";
-
-export default createPMRoute("user", "private-messages-new", NEW_FILTER);

[... diff too long, it was truncated ...]

GitHub sha: 9d5da2b383765becb824a8f3ff3665abc8e527fa

This commit appears in #14445 which was approved by lis2. It was merged by tgxworld.

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