Filter Duplicates in Chapter Selection (Closes #847)

This commit is contained in:
Rajarshee Chatterjee
2024-01-04 22:58:18 +05:30
parent a298ed81d7
commit e0e593bf9f
3 changed files with 35 additions and 22 deletions
+29 -16
View File
@@ -68,6 +68,7 @@ import { getChapterScreenRouteParams } from '../../utils/NavigationUtils';
import NovelScreenLoading from './components/LoadingAnimation/NovelScreenLoading';
import { useTrackerReducer } from '@redux/hooks';
import EpubIconButton from './components/EpubIconButton';
import { uniqBy } from 'lodash-es';
const Novel = ({ route, navigation }) => {
const item = route.params;
@@ -290,25 +291,37 @@ const Novel = ({ route, navigation }) => {
if (lastSelectedChapter.chapterId !== chapter.chapterId) {
if (lastSelectedChapter.chapterId > chapter.chapterId) {
setSelected(sel => [
...sel,
chapter,
...chapters.filter(
chap =>
(chap.chapterId <= chapter.chapterId ||
chap.chapterId >= lastSelectedChapter.chapterId) === false,
setSelected(sel =>
uniqBy(
[
...sel,
chapter,
...chapters.filter(
chap =>
(chap.chapterId <= chapter.chapterId ||
chap.chapterId >= lastSelectedChapter.chapterId) ===
false,
),
],
'chapterId',
),
]);
);
} else {
setSelected(sel => [
...sel,
chapter,
...chapters.filter(
chap =>
(chap.chapterId >= chapter.chapterId ||
chap.chapterId <= lastSelectedChapter.chapterId) === false,
setSelected(sel =>
uniqBy(
[
...sel,
chapter,
...chapters.filter(
chap =>
(chap.chapterId >= chapter.chapterId ||
chap.chapterId <= lastSelectedChapter.chapterId) ===
false,
),
],
'chapterId',
),
]);
);
}
}
}
@@ -42,14 +42,14 @@ const ChaptersSettingsSheet = ({
: false
}
onPress={() => {
if (filter.match('AND downloaded=0')) {
if (filter.match('AND downloaded=1')) {
filterChapters(
filter.replace(' AND downloaded=0', ' AND downloaded=1'),
filter.replace(' AND downloaded=1', ' AND downloaded=0'),
);
} else if (filter.match('AND downloaded=1')) {
filterChapters(filter.replace(' AND downloaded=1', ''));
} else if (filter.match('AND downloaded=0')) {
filterChapters(filter.replace(' AND downloaded=0', ''));
} else {
filterChapters(filter + ' AND downloaded=0');
filterChapters(filter + ' AND downloaded=1');
}
}}
/>
+1 -1
View File
@@ -126,7 +126,7 @@ const popularNovels = async (page: number) => {
const NovelsOnlineScraper = {
popularNovels,
parseNovelAndChapters,
parseChapter,
// parseChapter,
searchNovels,
};