Fix updates tab crash
This commit is contained in:
@@ -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}}) => (
|
||||
|
||||
Reference in New Issue
Block a user