diff --git a/src/database/queries/ChapterQueries.js b/src/database/queries/ChapterQueries.js
index 5f39f3d6..699dc8df 100644
--- a/src/database/queries/ChapterQueries.js
+++ b/src/database/queries/ChapterQueries.js
@@ -35,7 +35,7 @@ export const insertChapters = async (novelId, chapters) => {
};
const getChaptersQuery = (sort, filter) =>
- `SELECT * FROM chapters WHERE novelId = ? ${filter} ${sort}`;
+ `SELECT * FROM chapters WHERE novelId = ? ${filter ?? ""} ${sort ?? ""}`;
export const getChapters = (novelId, sort, filter) => {
return new Promise((resolve, reject) =>
diff --git a/src/redux/novel/novel.reducer.js b/src/redux/novel/novel.reducer.js
index 05cfbdcc..a94174af 100644
--- a/src/redux/novel/novel.reducer.js
+++ b/src/redux/novel/novel.reducer.js
@@ -82,12 +82,16 @@ const novelReducer = (state = initialState, action) => {
case CHAPTER_DOWNLOADING:
return {
...state,
- downloading: payload,
+ chapters: state.chapters.map((chapter) =>
+ chapter.chapterId === payload
+ ? { ...chapter, downloaded: 3 }
+ : chapter
+ ),
};
case CHAPTER_DOWNLOADED:
return {
...state,
- downloading: null,
+ // downloading: state.downloading.filter((id) => id === payload),
chapters: state.chapters.map((chapter) =>
chapter.chapterId === payload
? { ...chapter, downloaded: 1 }
diff --git a/src/screens/Novel/components/ChapterCard.js b/src/screens/Novel/components/ChapterCard.js
index 376e4f9f..1c093b88 100644
--- a/src/screens/Novel/components/ChapterCard.js
+++ b/src/screens/Novel/components/ChapterCard.js
@@ -14,12 +14,62 @@ const ChapterCard = ({
chapter,
extensionId,
theme,
- downloading,
+ // downloading,
downloadChapterAction,
deleteChapterAction,
}) => {
const navigation = useNavigation();
+ // console.log(downloading.includes(chapter.chapterId));
+
+ const displayDownloadButton = () => {
+ if (chapter.downloaded === 3) {
+ return (
+
+ );
+ } else if (chapter.downloaded === 1) {
+ return (
+
+ deleteChapterAction(
+ chapter.chapterId,
+ chapter.chapterName
+ )
+ }
+ style={{ margin: 2 }}
+ />
+ );
+ } else {
+ return (
+ {
+ downloadChapterAction(
+ extensionId,
+ novelUrl,
+ chapter.chapterUrl,
+ chapter.chapterName,
+ chapter.chapterId
+ );
+ // console.log(downloading);
+ }}
+ style={{ margin: 2 }}
+ />
+ );
+ }
+ };
+
return (
)}
-
- {downloading === chapter.chapterId ? (
-
- ) : (
- {
- if (!chapter.downloaded) {
- downloadChapterAction(
- extensionId,
- novelUrl,
- chapter.chapterUrl,
- chapter.chapterName,
- chapter.chapterId
- );
- } else {
- deleteChapterAction(
- chapter.chapterId,
- chapter.chapterName
- );
- }
- }}
- style={{ margin: 2 }}
- />
- )}
-
+ {displayDownloadButton()}
>
);
@@ -116,7 +126,7 @@ const ChapterCard = ({
const mapStateToProps = (state) => ({
theme: state.themeReducer.theme,
- downloading: state.novelReducer.downloading,
+ // downloading: state.novelReducer.downloading,
});
export default connect(mapStateToProps, {
diff --git a/src/screens/Novel/components/NovelHeader.js b/src/screens/Novel/components/NovelHeader.js
index b095d91f..4da3775a 100644
--- a/src/screens/Novel/components/NovelHeader.js
+++ b/src/screens/Novel/components/NovelHeader.js
@@ -8,7 +8,13 @@ import {
FlatList,
Share,
} from "react-native";
-import { TouchableRipple, IconButton, Button, Chip } from "react-native-paper";
+import {
+ TouchableRipple,
+ IconButton,
+ Button,
+ Chip,
+ Menu,
+} from "react-native-paper";
import { useNavigation } from "@react-navigation/native";
import * as WebBrowser from "expo-web-browser";
@@ -31,6 +37,10 @@ const NovelInfoHeader = ({
!loading && novel.followed !== 1 ? true : false
);
+ const [visible, setVisible] = useState(false);
+ const openMenu = () => setVisible(true);
+ const closeMenu = () => setVisible(false);
+
const renderGenreChip = ({ item }) => (
+
+
+ }
+ contentStyle={{ backgroundColor: "#242529" }}
+ >
+ {}}
+ title="Download all"
+ style={{ backgroundColor: "#242529" }}
+ titleStyle={{ color: theme.textColorPrimary }}
+ // onPress={{}}
+ />
+
{novel.novelSummary !== "" && (