From 7c42400aa29602a8cd9a41f1c6d9ee80f0e6fafc Mon Sep 17 00:00:00 2001
From: Audric Ackermann <audric@loki.network>
Date: Mon, 20 Dec 2021 11:56:34 +1100
Subject: [PATCH] fix crash of app on rendering pin item

---
 ts/components/leftpane/conversation-list-item/HeaderItem.tsx | 3 ++-
 ts/components/menu/Menu.tsx                                  | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/ts/components/leftpane/conversation-list-item/HeaderItem.tsx b/ts/components/leftpane/conversation-list-item/HeaderItem.tsx
index 8589f9be0..c8e69fc72 100644
--- a/ts/components/leftpane/conversation-list-item/HeaderItem.tsx
+++ b/ts/components/leftpane/conversation-list-item/HeaderItem.tsx
@@ -11,7 +11,8 @@ import { ContextConversationId } from './ConversationListItem';
 import { UserItem } from './UserItem';
 
 const NotificationSettingIcon = (props: { isMessagesSection: boolean }) => {
-  const convoSetting = useSelector(useConversationPropsById)?.currentNotificationSetting;
+  const convoId = useContext(ContextConversationId);
+  const convoSetting = useConversationPropsById(convoId)?.currentNotificationSetting;
 
   if (!props.isMessagesSection) {
     return null;
diff --git a/ts/components/menu/Menu.tsx b/ts/components/menu/Menu.tsx
index da980d193..f148a6b5c 100644
--- a/ts/components/menu/Menu.tsx
+++ b/ts/components/menu/Menu.tsx
@@ -155,11 +155,11 @@ export const getPinConversationMenuItem = (conversationId: string): JSX.Element
 
   if (isMessagesSection) {
     const conversation = getConversationController().get(conversationId);
-    const isPinned = conversation.isPinned();
+    const isPinned = conversation?.isPinned() || false;
 
     const togglePinConversation = async () => {
       if ((!isPinned && nbOfAlreadyPinnedConvos < maxNumberOfPinnedConversations) || isPinned) {
-        await conversation.setIsPinned(!isPinned);
+        await conversation?.setIsPinned(!isPinned);
       } else {
         ToastUtils.pushToastWarning(
           'pinConversationLimitToast',