A platform for community discussion. Free, open, simple.
FIX: correctly sort channels with null last message (#23672)
Joffrey JAFFEUXdb558dc3fcab
diff --git a/plugins/chat/assets/javascripts/discourse/services/chat-channels-manager.js b/plugins/chat/assets/javascripts/discourse/services/chat-channels-manager.jsindex f55e58fb849..882353e6d45 100644--- a/plugins/chat/assets/javascripts/discourse/services/chat-channels-manager.js+++ b/plugins/chat/assets/javascripts/discourse/services/chat-channels-manager.js@@ -2,7 +2,7 @@ import Service, { inject as service } from "@ember/service";import { debounce } from "discourse-common/utils/decorators";import Promise from "rsvp";import ChatChannel from "discourse/plugins/chat/discourse/models/chat-channel";-import { tracked } from "@glimmer/tracking";+import { cached, tracked } from "@glimmer/tracking";import { TrackedObject } from "@ember-compat/tracked-built-ins";import { popupAjaxError } from "discourse/lib/ajax-error";@@ -106,6 +106,7 @@ export default class ChatChannelsManager extends Service {);}+ @cachedget publicMessageChannels() {return this.channels.filter(@@ -115,6 +116,7 @@ export default class ChatChannelsManager extends Service {.sort((a, b) => a?.slug?.localeCompare?.(b?.slug));}+ @cachedget directMessageChannels() {return this.#sortDirectMessageChannels(this.channels.filter((channel) => {@@ -151,11 +153,11 @@ export default class ChatChannelsManager extends Service {#sortDirectMessageChannels(channels) {return channels.sort((a, b) => {- if (!a.lastMessage) {+ if (!a.lastMessage.id) {return 1;}- if (!b.lastMessage) {+ if (!b.lastMessage.id) {return -1;}