Fix updates tab crash

This commit is contained in:
Rajarshee Chatterjee
2021-10-18 20:50:03 +05:30
parent eb9516adda
commit bca620ea37
+10 -1
View File
@@ -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}) => {
)}
<SectionList
contentContainerStyle={styles.flatList}
sections={searchText ? searchResults : updates}
sections={searchText ? searchResults : sectionedUpdates}
keyExtractor={(item, index) => index.toString()}
renderItem={renderItem}
renderSectionHeader={({section: {date}}) => (