diff options
author | ankit-thanekar007 <ankit.thanekar007@gmail.com> | 2021-03-11 14:57:37 -0800 |
---|---|---|
committer | ankit-thanekar007 <ankit.thanekar007@gmail.com> | 2021-03-15 11:33:28 -0700 |
commit | c55cf9fec6b252b9ef953122950a79b7bf8abe94 (patch) | |
tree | 68acd26197a07d8d6a022ab7f54bf7007f06af52 /src | |
parent | e858873285cb862e365331ce183fb3d2282f239c (diff) |
TMA-643-Friend requests added, need to add section of 5
Diffstat (limited to 'src')
-rw-r--r-- | src/components/notifications/Notification.tsx | 3 | ||||
-rw-r--r-- | src/screens/main/NotificationsScreen.tsx | 45 |
2 files changed, 29 insertions, 19 deletions
diff --git a/src/components/notifications/Notification.tsx b/src/components/notifications/Notification.tsx index f83abcbc..c8a8aa06 100644 --- a/src/components/notifications/Notification.tsx +++ b/src/components/notifications/Notification.tsx @@ -256,10 +256,11 @@ const styles = StyleSheet.create({ container: { flexDirection: 'row', height: Math.round(SCREEN_HEIGHT / 10), - width: SCREEN_WIDTH * 0.9, + width: SCREEN_WIDTH, flex: 1, alignSelf: 'center', alignItems: 'center', + paddingHorizontal: '8%', }, avatarContainer: { height: 42, diff --git a/src/screens/main/NotificationsScreen.tsx b/src/screens/main/NotificationsScreen.tsx index 1dcae36e..c92abdbd 100644 --- a/src/screens/main/NotificationsScreen.tsx +++ b/src/screens/main/NotificationsScreen.tsx @@ -48,7 +48,10 @@ const NotificationsScreen: React.FC = () => { const [showSPNotifyPopUp, setShowSPNotifyPopUp] = useState(false); const {user: loggedInUser} = useSelector((state: RootState) => state.user); const [sectionedNotifications, setSectionedNotifications] = useState< - {title: 'Today' | 'Yesterday' | 'This Week'; data: NotificationType[]}[] + { + title: 'Friend Requests' | 'Today' | 'Yesterday' | 'This Week'; + data: NotificationType[]; + }[] >([]); const dispatch = useDispatch(); @@ -112,6 +115,7 @@ const NotificationsScreen: React.FC = () => { let todays = []; let yesterdays = []; let thisWeeks = []; + let friendRequests = []; for (const n of sortedNotifications) { const notificationDate = moment(n.timestamp); const dateAge = getDateAge(notificationDate); @@ -120,24 +124,33 @@ const NotificationsScreen: React.FC = () => { } const unread = lastViewed ? lastViewed.diff(notificationDate) < 0 : false; const newN = {...n, unread}; - switch (dateAge) { - case 'today': - todays.push(newN); - continue; - case 'yesterday': - yesterdays.push(newN); - continue; - case 'thisWeek': - thisWeeks.push(newN); - continue; - default: - continue; + + if (n.notification_type === 'FRD_REQ') { + friendRequests.push(newN); + } else { + switch (dateAge) { + case 'today': + todays.push(newN); + continue; + case 'yesterday': + yesterdays.push(newN); + continue; + case 'thisWeek': + thisWeeks.push(newN); + continue; + default: + continue; + } } } setSectionedNotifications( - todays.length === 0 && yesterdays.length === 0 && thisWeeks.length === 0 + todays.length === 0 && + yesterdays.length === 0 && + thisWeeks.length === 0 && + friendRequests.length === 0 ? [] : [ + {title: 'Friend Requests', data: friendRequests}, {title: 'Today', data: todays}, {title: 'Yesterday', data: yesterdays}, {title: 'This Week', data: thisWeeks}, @@ -145,10 +158,6 @@ const NotificationsScreen: React.FC = () => { ); }, [lastViewed, notifications, showSPNotifyPopUp]); - useEffect(() => { - console.log(sectionedNotifications); - }, [sectionedNotifications]); - const renderNotification = ({item}: {item: NotificationType}) => ( <Notification item={item} |