From 5933716cf0f3f3c602aff4fe133b1eb5893e80df Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Tue, 5 Jan 2021 14:32:50 -0500 Subject: added logic to hide empty categories (#164) --- src/screens/main/NotificationsScreen.tsx | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/screens/main/NotificationsScreen.tsx b/src/screens/main/NotificationsScreen.tsx index 2343215f..d6d47b02 100644 --- a/src/screens/main/NotificationsScreen.tsx +++ b/src/screens/main/NotificationsScreen.tsx @@ -88,18 +88,9 @@ const NotificationsScreen: React.FC = () => { } } setSectionedNotifications([ - { - title: 'Today', - data: todays, - }, - { - title: 'Yesterday', - data: yesterdays, - }, - { - title: 'This Week', - data: thisWeeks, - }, + {title: 'Today', data: todays}, + {title: 'Yesterday', data: yesterdays}, + {title: 'This Week', data: thisWeeks}, ]); }, [lastViewed, notifications]); @@ -107,11 +98,12 @@ const NotificationsScreen: React.FC = () => { ); - const renderSectionHeader = ({section: {title}}) => ( - - {title} - - ); + const renderSectionHeader = ({section: {title, data}}) => + data.length !== 0 && ( + + {title} + + ); return ( -- cgit v1.2.3-70-g09d2