Merge pull request #2112 from Bilb/fix-pin-item-crash

fix crash of app on rendering pin item
This commit is contained in:
Audric Ackermann 2021-12-20 13:29:26 +11:00 committed by GitHub
commit 1424e13a68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -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;

View File

@ -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',