Skip to content

Commit

Permalink
perf: add useMemo for contactsAndExtraItems
Browse files Browse the repository at this point in the history
  • Loading branch information
WofWca committed Jan 6, 2025
1 parent ae1fdcb commit 94893d5
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions packages/frontend/src/components/dialogs/CreateChat/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,30 @@ function CreateChatMain(props: CreateChatMainProps) {
ADD_BROADCAST_LIST,
ADD_CONTACT,
}
const contactsAndExtraItems = [
...(needToRenderAddContactQRScan
? [ExtraItemType.ADD_CONTACT_QR_SCAN]
: []),
...(needToRenderAddGroup ? [ExtraItemType.ADD_GROUP] : []),
...(needToRenderAddBroadcastList ? [ExtraItemType.ADD_BROADCAST_LIST] : []),
...contactIds,
...(needToRenderAddContact ? [ExtraItemType.ADD_CONTACT] : []),
]
const contactsAndExtraItems = useMemo(
() => [
...(needToRenderAddContactQRScan
? [ExtraItemType.ADD_CONTACT_QR_SCAN]
: []),
...(needToRenderAddGroup ? [ExtraItemType.ADD_GROUP] : []),
...(needToRenderAddBroadcastList
? [ExtraItemType.ADD_BROADCAST_LIST]
: []),
...contactIds,
...(needToRenderAddContact ? [ExtraItemType.ADD_CONTACT] : []),
],
[
ExtraItemType.ADD_BROADCAST_LIST,
ExtraItemType.ADD_CONTACT,
ExtraItemType.ADD_CONTACT_QR_SCAN,
ExtraItemType.ADD_GROUP,
contactIds,
needToRenderAddBroadcastList,
needToRenderAddContact,
needToRenderAddContactQRScan,
needToRenderAddGroup,
]
)

const openQRScan = async () => {
const [qrCode, qrCodeSVG] =
Expand Down

0 comments on commit 94893d5

Please sign in to comment.