From 1dcbe1f0ca3a95e32cf79bac889237db29ba31cf Mon Sep 17 00:00:00 2001 From: cha0s Date: Sat, 25 Jul 2020 09:33:47 -0500 Subject: [PATCH] feat: unread for friend requests --- src/client/chat--center.jsx | 7 ++++++- src/client/chat--left.jsx | 5 +++-- src/client/chat--leftFriends.jsx | 6 +++++- src/client/chat--leftFriends.scss | 6 ++++++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/client/chat--center.jsx b/src/client/chat--center.jsx index e54f77b..0cfe5f4 100644 --- a/src/client/chat--center.jsx +++ b/src/client/chat--center.jsx @@ -5,6 +5,8 @@ import React from 'react'; import {useSelector} from 'react-redux'; import { + idSelector, + pendingFriendshipSelector, unreadChannelSelector, unreadUserSelector, } from '~/common/state/user'; @@ -16,9 +18,12 @@ import ChatMessages from './chat--messages'; export default function ChatCenter(props) { const {onButton} = props; const channel = useChannel(); + const id = useSelector(idSelector); + const pendingFriendship = useSelector(pendingFriendshipSelector) + .filter(({addeeId}) => addeeId === id).length; const unreadChannel = useSelector(unreadChannelSelector); const unreadUser = useSelector(unreadUserSelector); - const unread = unreadChannel + unreadUser; + const unread = pendingFriendship + unreadChannel + unreadUser; return (
addeeId === id).length; const unreadChannel = useSelector(unreadChannelSelector); const unreadUser = useSelector(unreadUserSelector); const showsAsOpen = isOpen; @@ -37,7 +38,7 @@ export default function ChatLeft() { label: 'Chat', }, { - count: unreadUser + pendingFriendship.filter(({addeeId}) => addeeId === id).length, + count: unreadUser + pendingFriendship, icon: '😁', label: 'Friends', }, diff --git a/src/client/chat--leftFriends.jsx b/src/client/chat--leftFriends.jsx index 3c4d6a4..78cec29 100644 --- a/src/client/chat--leftFriends.jsx +++ b/src/client/chat--leftFriends.jsx @@ -71,7 +71,11 @@ export default function ChatLeftFriends() { {pendingIncomingFriendship.length > 0 && ( <> -

Incoming requests

+

+ {pendingIncomingFriendship.length} + {' '} + Incoming requests +