DEV: Reduce the number of IntersectionObservers (#22933)

…by adding the `chat/track-message` modifier only to the last thread rather than all of them

(plus: don't use Ember's `lastObject`)
This commit is contained in:
Jarek Radosz 2023-08-02 15:24:30 +02:00 committed by GitHub
parent 13b13a758c
commit 09502cf627
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

View File

@ -15,13 +15,10 @@
{{#each this.sortedThreads as |thread|}}
<Chat::ThreadList::Item
@thread={{thread}}
{{chat/track-message
(if
(eq thread this.sortedThreads.lastObject)
this.loadThreads
(fn (noop))
)
}}
{{(if
(eq thread this.lastThread)
(modifier "chat/track-message" this.loadThreads)
)}}
/>
{{else}}
{{#if this.threadsCollection.fetchedOnce}}

View File

@ -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;
}