Skip to content

Commit 8c18aa9

Browse files
committed
fix: app hang on attach contact sometimes
Closes #5723. It seems that sometimes this causes front-end to basically infinitely spam the backend with `get_contacts_by_ids`. `isContactLoaded` also starts returning `true` as soon as we have started loading a contact, and not only when we have loaded it. This might not completely fix such a potential bug, but this should at least make it not happen in practice. This bug has likely been surfaced by 9bb605c (#5581).
1 parent dc92a40 commit 8c18aa9

File tree

1 file changed

+3
-10
lines changed
  • packages/frontend/src/components/dialogs/SelectContact

1 file changed

+3
-10
lines changed

packages/frontend/src/components/dialogs/SelectContact/index.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ export default function SelectContactDialog({
2828
onOk: (contact: T.Contact) => void
2929
} & DialogProps) {
3030
const [queryStr, setQueryStr] = useState('')
31-
const { contactIds, contactCache, loadContacts } = useLazyLoadedContacts(
32-
C.DC_GCL_ADD_SELF,
33-
queryStr
34-
)
31+
const { contactIds, contactCache, loadContacts, isContactLoaded } =
32+
useLazyLoadedContacts(C.DC_GCL_ADD_SELF, queryStr)
3533
const tx = useTranslationFunction()
3634

3735
const selectContactListRef = useRef<HTMLDivElement>(null)
@@ -71,12 +69,7 @@ export default function SelectContactDialog({
7169
ref={infiniteLoaderRef}
7270
itemCount={contactIds.length}
7371
loadMoreItems={loadContacts}
74-
// perf: consider using `isContactLoaded` from `useLazyLoadedContacts`
75-
// otherwise sometimes we might load the same contact twice (performance thing)
76-
// See https://github.com/bvaughn/react-window/issues/765
77-
isItemLoaded={index =>
78-
contactCache[contactIds[index]] != undefined
79-
}
72+
isItemLoaded={isContactLoaded}
8073
// minimumBatchSize={100}
8174
>
8275
{({ onItemsRendered, ref }) => (

0 commit comments

Comments
 (0)