From 24219f0a099c6a1d2f38e952f2f3c05a358352fa Mon Sep 17 00:00:00 2001 From: SmashinFries Date: Wed, 22 Jun 2022 00:45:21 -0500 Subject: [PATCH] format data if not empty --- src/navigation/tabs/listTabs.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/navigation/tabs/listTabs.tsx b/src/navigation/tabs/listTabs.tsx index c8605e5..21ba90d 100644 --- a/src/navigation/tabs/listTabs.tsx +++ b/src/navigation/tabs/listTabs.tsx @@ -46,9 +46,9 @@ export const ListTabs = ({ navigation, route }: ListTabProp) => { const filterData = (status: string) => { const statusData = data?.lists.filter((item) => item.status === status); - let formattedData = (statusData.length > 0) ? statusData[0].entries : []; - if (format === 'NOVEL' || format === 'MANGA') { - formattedData = statusData[0].entries.filter((item: MediaCollectionEntries) => { + let formattedData = (statusData.length > 0 && statusData[0].entries !== undefined) ? statusData[0].entries : []; + if (format === 'NOVEL' || format === 'MANGA' && formattedData.length > 0) { + formattedData = formattedData.filter((item: MediaCollectionEntries) => { if (format === 'MANGA') return(item.media.format !== 'NOVEL'); return (item.media.format === format); }); @@ -72,7 +72,7 @@ export const ListTabs = ({ navigation, route }: ListTabProp) => { return ({ data: filterData(listStatus.toUpperCase()), listStatus: listStatus, colors: { colors, dark } }); } - if (listLoad) return + if (listLoad) return return (