From 09502cf627df11ff1d61cefb59c8805fa63223b5 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Wed, 2 Aug 2023 15:24:30 +0200 Subject: [PATCH] DEV: Reduce the number of IntersectionObservers (#22933) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …by adding the `chat/track-message` modifier only to the last thread rather than all of them (plus: don't use Ember's `lastObject`) --- .../discourse/components/chat/thread-list.hbs | 11 ++++------- .../discourse/components/chat/thread-list.js | 4 ++++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/thread-list.hbs b/plugins/chat/assets/javascripts/discourse/components/chat/thread-list.hbs index ed91b635bc3..e7117ba65fe 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat/thread-list.hbs +++ b/plugins/chat/assets/javascripts/discourse/components/chat/thread-list.hbs @@ -15,13 +15,10 @@ {{#each this.sortedThreads as |thread|}} {{else}} {{#if this.threadsCollection.fetchedOnce}} diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/thread-list.js b/plugins/chat/assets/javascripts/discourse/components/chat/thread-list.js index c3d572d5560..0d9b3b6c1fe 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat/thread-list.js +++ b/plugins/chat/assets/javascripts/discourse/components/chat/thread-list.js @@ -57,6 +57,10 @@ export default class ChatThreadList extends Component { }); } + get lastThread() { + return this.sortedThreads[this.sortedThreads.length - 1]; + } + get shouldRender() { return !!this.args.channel; }