fix: Persists Bookmark State (Closes #676)
This commit is contained in:
@@ -158,7 +158,7 @@ const ChapterContent = ({ route, navigation }) => {
|
||||
if (!(id && (result = await getChapterFromDb(id)))) {
|
||||
result = await fetchChapter(sourceId, novelUrl, chapterUrl);
|
||||
}
|
||||
setChapter(result);
|
||||
setChapter({ ...result, bookmark });
|
||||
} catch (e) {
|
||||
setError(e.message);
|
||||
showToast(e.message);
|
||||
@@ -331,6 +331,9 @@ const ChapterContent = ({ route, navigation }) => {
|
||||
return <ErrorScreenV2 error={error} />;
|
||||
}
|
||||
|
||||
const bookmarkChapter = () =>
|
||||
setChapter(prevVal => ({ ...prevVal, bookmark: !prevVal?.bookmark }));
|
||||
|
||||
return (
|
||||
<>
|
||||
<WebViewReader
|
||||
@@ -357,7 +360,8 @@ const ChapterContent = ({ route, navigation }) => {
|
||||
{!hidden && (
|
||||
<>
|
||||
<ReaderAppbar
|
||||
bookmark={bookmark}
|
||||
bookmark={chapter.bookmark}
|
||||
bookmarkChapter={bookmarkChapter}
|
||||
novelName={novelName}
|
||||
chapterId={chapterId}
|
||||
chapterName={chapterName || chapter.chapterName}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useNavigation } from '@react-navigation/native';
|
||||
import React, { useState } from 'react';
|
||||
import React from 'react';
|
||||
import { StyleSheet, View } from 'react-native';
|
||||
import color from 'color';
|
||||
|
||||
@@ -17,10 +17,10 @@ const ReaderAppbar = ({
|
||||
tts,
|
||||
textToSpeech,
|
||||
theme,
|
||||
bookmarkChapter,
|
||||
}) => {
|
||||
const dispatch = useAppDispatch();
|
||||
const { goBack } = useNavigation();
|
||||
const [bookmarked, setBookmarked] = useState(bookmark);
|
||||
|
||||
return (
|
||||
<Animated.View
|
||||
@@ -66,11 +66,11 @@ const ReaderAppbar = ({
|
||||
/>
|
||||
|
||||
<IconButtonV2
|
||||
name={bookmarked ? 'bookmark' : 'bookmark-outline'}
|
||||
name={bookmark ? 'bookmark' : 'bookmark-outline'}
|
||||
size={24}
|
||||
onPress={() => {
|
||||
dispatch(bookmarkChapterAction([{ bookmark, chapterId }]));
|
||||
setBookmarked(!bookmarked);
|
||||
bookmarkChapter();
|
||||
}}
|
||||
iconColor={theme.onSurface}
|
||||
theme={theme}
|
||||
|
||||
Reference in New Issue
Block a user