diff --git a/src/screens/reader/ReaderScreen.tsx b/src/screens/reader/ReaderScreen.tsx index 7eb7e0374..1418928e8 100644 --- a/src/screens/reader/ReaderScreen.tsx +++ b/src/screens/reader/ReaderScreen.tsx @@ -1,4 +1,4 @@ -import React, { useRef, useCallback } from 'react'; +import React, { useRef, useCallback, useState, useEffect } from 'react'; import { DrawerLayoutAndroid } from 'react-native'; import { useChapterGeneralSettings, useTheme } from '@hooks/persisted'; @@ -63,6 +63,11 @@ export const ChapterContent = ({ const readerSheetRef = useRef(null); const theme = useTheme(); const { pageReader = false, keepScreenOn } = useChapterGeneralSettings(); + const [bookmarked, setBookmarked] = useState(chapter.bookmark); + + useEffect(() => { + setBookmarked(chapter.bookmark); + }, [chapter]); const { hidden, @@ -146,7 +151,12 @@ export const ChapterContent = ({ {!hidden ? ( <> - + void; } -const ReaderAppbar = ({ goBack, theme }: ReaderAppbarProps) => { +const ReaderAppbar = ({ + goBack, + theme, + bookmarked, + setBookmarked, +}: ReaderAppbarProps) => { const { chapter, novel } = useChapterContext(); - const [bookmarked, setBookmarked] = useState(chapter.bookmark); - useEffect(() => { - setBookmarked(chapter.bookmark); - }, [chapter]); + return ( ) { useEffect(() => { setLoading(true); getChapter().finally(() => setLoading(false)); + if (!incognitoMode) { insertHistory(chapter.id); - setLastRead(chapter); + getDbChapter(chapter.id).then(result => setLastRead(result)); } + + return () => { + if (!incognitoMode) { + getDbChapter(chapter.id).then(result => setLastRead(result)); + } + }; }, [chapter]); const refetch = () => {