From bca620ea3793b4b4cd54cde9ce5e7117ce1734bb Mon Sep 17 00:00:00 2001 From: Rajarshee Chatterjee Date: Mon, 18 Oct 2021 20:50:03 +0530 Subject: [PATCH] Fix updates tab crash --- src/screens/updates/UpdatesScreen.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/screens/updates/UpdatesScreen.js b/src/screens/updates/UpdatesScreen.js index 58181534..08a9c9b8 100644 --- a/src/screens/updates/UpdatesScreen.js +++ b/src/screens/updates/UpdatesScreen.js @@ -24,6 +24,7 @@ import { deleteChapterAction, downloadChapterAction, } from '../../redux/novel/novel.actions'; +import {showToast} from '../../hooks/showToast'; const Updates = ({navigation}) => { const theme = useTheme(); @@ -40,6 +41,14 @@ const Updates = ({navigation}) => { const [searchResults, setSearchResults] = useState([]); const [refreshing, setRefreshing] = useState(false); + let sectionedUpdates = []; + + if (updates.length && updates[0].data !== undefined) { + sectionedUpdates = updates; + } else { + showToast('Update your library to show updates.'); + } + useFocusEffect( useCallback(() => { dispatch(getUpdatesAction()); @@ -168,7 +177,7 @@ const Updates = ({navigation}) => { )} index.toString()} renderItem={renderItem} renderSectionHeader={({section: {date}}) => (