File tree Expand file tree Collapse file tree 3 files changed +12
-10
lines changed
packages/frontend/src/components/dialogs Expand file tree Collapse file tree 3 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ export function AddMemberDialog({
2626 const {
2727 contactIds,
2828 contactCache,
29+ isContactLoaded,
2930 loadContacts,
3031 queryStrIsValidEmail,
3132 refreshContacts,
@@ -55,6 +56,7 @@ export function AddMemberDialog({
5556
5657 contactIds,
5758 contactCache,
59+ isContactLoaded,
5860 loadContacts,
5961 refreshContacts,
6062
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ export function AddMemberInnerDialog({
3232
3333 contactIds,
3434 contactCache,
35+ isContactLoaded,
3536 loadContacts,
3637 refreshContacts,
3738
@@ -47,6 +48,7 @@ export function AddMemberInnerDialog({
4748
4849 contactIds : number [ ]
4950 contactCache : { [ id : number ] : T . Contact | undefined }
51+ isContactLoaded : ( index : number ) => boolean
5052 loadContacts : ( startIndex : number , stopIndex : number ) => Promise < void >
5153 refreshContacts : ( ) => void
5254
@@ -230,14 +232,9 @@ export function AddMemberInnerDialog({
230232 // with wrong indices.
231233 // See `CreateChatMain` component.
232234 loadMoreItems = { loadContacts }
233- // perf: consider using `isContactLoaded` from `useLazyLoadedContacts`
234- // otherwise sometimes we might load the same contact twice (performance thing)
235- // See https://github.com/bvaughn/react-window/issues/765
236235 isItemLoaded = { index => {
237236 const isExtraItem = index >= contactIds . length
238- return isExtraItem
239- ? true
240- : contactCache [ contactIds [ index ] ] != undefined
237+ return isExtraItem ? true : isContactLoaded ( index )
241238 } }
242239 // minimumBatchSize={100}
243240 >
Original file line number Diff line number Diff line change @@ -173,6 +173,7 @@ function CreateChatMain(props: CreateChatMainProps) {
173173 const {
174174 contactIds,
175175 contactCache,
176+ isContactLoaded,
176177 loadContacts,
177178 queryStrIsValidEmail,
178179 refreshContacts,
@@ -366,15 +367,17 @@ function CreateChatMain(props: CreateChatMainProps) {
366367 contactIds . indexOf ( contactsAndExtraItems [ stopInd ] )
367368 )
368369 } }
369- // perf: consider using `isContactLoaded` from `useLazyLoadedContacts`
370- // otherwise sometimes we might load the same contact twice (performance thing)
371- // See https://github.com/bvaughn/react-window/issues/765
372370 isItemLoaded = { index => {
373371 const isExtraItem = contactsAndExtraItems [ index ] < - 100
374372 if ( isExtraItem ) {
375373 return true
376374 }
377- return contactCache [ contactsAndExtraItems [ index ] ] != undefined
375+ // Again, the indices are shifted
376+ // due to the existence of extra items.
377+ const indInContactIds = contactIds . indexOf (
378+ contactsAndExtraItems [ index ]
379+ )
380+ return isContactLoaded ( indInContactIds )
378381 } }
379382 // minimumBatchSize={100}
380383 >
You can’t perform that action at this time.
0 commit comments