From 12a29178aaacd81734b82a29361b7874c958d2ad Mon Sep 17 00:00:00 2001 From: talksik Date: Mon, 30 May 2022 11:52:54 -0500 Subject: [PATCH] not having it if it's too high of a index --- .../src/components/ConversationList.tsx | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/desktop/src/components/ConversationList.tsx b/packages/desktop/src/components/ConversationList.tsx index 75193ae..1a56cf3 100644 --- a/packages/desktop/src/components/ConversationList.tsx +++ b/packages/desktop/src/components/ConversationList.tsx @@ -114,13 +114,19 @@ export function ConversationRow({ const rendersCount = useRendersCount(); console.warn('RENDER COUNT | CONVERSATION LIST ROW | ', rendersCount); - const keyboardShortcut = useMemo(() => index + 1, [index]); + const keyboardShortcut = useMemo(() => { + if (index < 9) { + return index + 1; + } - const handleSelectConversation = useCallback( - () => selectConversation(conversation.id), - [conversation.id, selectConversation], - ); - useKeyPressEvent(`${keyboardShortcut.toString()}`, handleSelectConversation); + return undefined; + }, [index]); + + const handleSelectConversation = useCallback(() => { + selectConversation(conversation.id); + }, [conversation.id, selectConversation]); + + useKeyPressEvent(`${keyboardShortcut?.toString()}`, handleSelectConversation); return ( @@ -139,7 +145,7 @@ export function ConversationRow({ )} - + {keyboardShortcut && }