Skip to content

Commit

Permalink
Add Setting to Jump to Last Read Chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
rajarsheechatterjee authored and CD-Z committed Jan 9, 2024
1 parent 0d670c7 commit e0e3e66
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/screens/novel/NovelScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const Novel = ({ route, navigation }) => {
useFabForContinueReading = false,
defaultChapterSort = 'ORDER BY chapterId ASC',
disableHapticFeedback = false,
jumpToLastReadChapter = false,
} = useSettings();

const {
Expand Down Expand Up @@ -651,6 +652,18 @@ const Novel = ({ route, navigation }) => {
</Portal>
<View style={styles.flashlistContainer}>
<FlashList
onLayout={() => {
if (jumpToLastReadChapter) {
const lastReadChapterIdx = chapters.findIndex(
chapter => chapter.chapterId === lastReadChapter.chapterId,
);

flatlistRef.current.scrollToIndex({
animated: true,
index: lastReadChapterIdx,
});
}
}}
ref={flatlistRef}
estimatedItemSize={64}
data={chapters}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const GenralSettings: React.FC<GenralSettingsProps> = ({ navigation }) => {
refreshNovelMetadata = false,
disableHapticFeedback = false,
useLibraryFAB = false,
jumpToLastReadChapter = false,
} = useSettings();

const { showLastUpdateTime = true } = useSelector(
Expand Down Expand Up @@ -215,6 +216,18 @@ const GenralSettings: React.FC<GenralSettingsProps> = ({ navigation }) => {
onPress={defaultChapterSortModal.setTrue}
theme={theme}
/>
<SwitchSetting
label={getString(
'moreScreen.settingsScreen.generalSettingsScreen.jumpToLastReadChapter',
)}
value={jumpToLastReadChapter}
onPress={() =>
dispatch(
setAppSettings('jumpToLastReadChapter', !jumpToLastReadChapter),
)
}
theme={theme}
/>
<List.Divider theme={theme} />
<List.SubHeader theme={theme}>
{getString(
Expand Down
3 changes: 2 additions & 1 deletion strings/languages/en/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@
"epubLocation": "EPUB Location",
"epubLocationDescription": "The place where you open and export your EPUB files.",
"downloadNewChapters": "Download new chapters",
"disableHapticFeedback": "Disable haptic feedback"
"disableHapticFeedback": "Disable haptic feedback",
"jumpToLastReadChapter": "Jump to last read chapter in list"
},
"readerSettings": {
"title": "Reader",
Expand Down
1 change: 1 addition & 0 deletions strings/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export interface StringMap {
'moreScreen.settingsScreen.generalSettingsScreen.epubLocationDescription': 'string';
'moreScreen.settingsScreen.generalSettingsScreen.downloadNewChapters': 'string';
'moreScreen.settingsScreen.generalSettingsScreen.disableHapticFeedback': 'string';
'moreScreen.settingsScreen.generalSettingsScreen.jumpToLastReadChapter': 'string';
'moreScreen.settingsScreen.readerSettings.title': 'string';
'moreScreen.settingsScreen.readerSettings.readerTheme': 'string';
'moreScreen.settingsScreen.readerSettings.preset': 'string';
Expand Down

0 comments on commit e0e3e66

Please sign in to comment.