diff --git a/src/database/queries/ChapterQueries.ts b/src/database/queries/ChapterQueries.ts index 07bb1cd9..81e6674e 100644 --- a/src/database/queries/ChapterQueries.ts +++ b/src/database/queries/ChapterQueries.ts @@ -16,10 +16,10 @@ const db = SQLite.openDatabase('lnreader.db'); const insertChapterQuery = ` INSERT INTO Chapter ( - url, name, releaseTime, novelId + url, name, releaseTime, novelId, chapterNumber ) Values - (?, ?, ?, ?) + (?, ?, ?, ?, ?) `; export const insertChapters = async ( @@ -36,8 +36,9 @@ export const insertChapters = async ( [ chapter.url, chapter.name, - chapter.releaseTime ? chapter.releaseTime : '', + chapter.releaseTime || '', novelId, + chapter.chapterNumber || null, ], noop, txnErrorCallback, diff --git a/src/database/tables/ChapterTable.ts b/src/database/tables/ChapterTable.ts index fcfb7033..be303dba 100644 --- a/src/database/tables/ChapterTable.ts +++ b/src/database/tables/ChapterTable.ts @@ -10,6 +10,7 @@ export const createChapterTableQuery = ` readTime TEXT, isDownloaded INTEGER DEFAULT 0, updatedTime TEXT, + chapterNumber REAL NULL, FOREIGN KEY (novelId) REFERENCES Novel(id) ON DELETE CASCADE ) `; diff --git a/src/screens/novel/components/ChapterItem.tsx b/src/screens/novel/components/ChapterItem.tsx index cdfd48f3..e3db28d4 100644 --- a/src/screens/novel/components/ChapterItem.tsx +++ b/src/screens/novel/components/ChapterItem.tsx @@ -50,12 +50,15 @@ const ChapterItem: React.FC = ({ isUpdateCard, novelName, }) => { - const { id, name, unread, releaseTime, bookmark } = chapter; + const { id, name, unread, releaseTime, bookmark, chapterNumber } = chapter; const [deleteChapterMenuVisible, setDeleteChapterMenuVisible] = useState(false); const showDeleteChapterMenu = () => setDeleteChapterMenuVisible(true); const hideDeleteChapterMenu = () => setDeleteChapterMenuVisible(false); - const chapterNumber = parseChapterNumber(novelName, name); + const chapNum = chapterNumber + ? chapterNumber + : parseChapterNumber(novelName, name); + const parsedTime = dayjs(releaseTime); return ( = ({ ]} numberOfLines={1} > - {showChapterTitles - ? name - : `Chapter ${chapterNumber} • ID: ${id}`} + {showChapterTitles ? name : `Chapter ${chapNum} • ID: ${id}`} @@ -131,7 +132,7 @@ const ChapterItem: React.FC = ({ ]} numberOfLines={1} > - {dayjs(releaseTime).format('LL')} + {parsedTime.isValid() ? parsedTime.format('LL') : releaseTime} ) : null} {showProgressPercentage?.(chapter)} diff --git a/src/screens/novel/components/Info/NovelInfoComponents.tsx b/src/screens/novel/components/Info/NovelInfoComponents.tsx index 9dcae46b..0bf12e81 100644 --- a/src/screens/novel/components/Info/NovelInfoComponents.tsx +++ b/src/screens/novel/components/Info/NovelInfoComponents.tsx @@ -144,23 +144,12 @@ const NovelTitle = ({ onLongPress={onLongPress} onPress={onPress} style={[styles.novelTitle, { color: theme.onBackground }]} + numberOfLines={4} > {children} ); -const NovelAuthor = ({ - theme, - children, -}: { - theme: ThemeColors; - children: React.ReactNode; -}) => ( - - {children} - -); - const NovelInfo = ({ theme, children, @@ -282,7 +271,6 @@ export { CoverImage, NovelThumbnail, NovelTitle, - NovelAuthor, NovelInfo, FollowButton, TrackerButton, @@ -311,9 +299,6 @@ const styles = StyleSheet.create({ novelTitle: { fontSize: 20, }, - novelAuthor: { - fontSize: 14, - }, novelInfo: { fontSize: 14, }, diff --git a/src/screens/novel/components/Info/NovelInfoHeader.tsx b/src/screens/novel/components/Info/NovelInfoHeader.tsx index f66aa5c3..04c1a626 100644 --- a/src/screens/novel/components/Info/NovelInfoHeader.tsx +++ b/src/screens/novel/components/Info/NovelInfoHeader.tsx @@ -11,7 +11,6 @@ import { showToast } from '@utils/showToast'; import { CoverImage, - NovelAuthor, NovelInfo, NovelInfoContainer, NovelThumbnail, @@ -85,65 +84,56 @@ const NovelInfoHeader = ({ setCustomNovelCover={setCustomNovelCover} /> - - navigation.replace('GlobalSearchScreen', { - searchText: novel.name, - }) - } - onLongPress={() => { - Clipboard.setStringAsync(novel.name).then(() => - showToast('Copied to clipboard: ' + novel.name), - ); - }} - > - {novel.name} - - - {`ID: ${novel.id}`} - - <> - + + + navigation.replace('GlobalSearchScreen', { + searchText: novel.name, + }) + } + onLongPress={() => { + Clipboard.setStringAsync(novel.name).then(() => + showToast('Copied to clipboard: ' + novel.name), + ); + }} + > + {novel.name} + + + {novel.author && ( + - - {novel.author || 'Unknown author'} - + {novel.author} - + )} + {novel.artist && ( + - - {novel.artist || 'Unknown artist'} - + {novel.artist} - - - - {(novel.status || 'Unknown status') + ' • ' + novel.pluginId} - - - + )} + + + + {(novel.status || 'Unknown status') + ' • ' + novel.pluginId} + + @@ -201,6 +191,7 @@ export default memo(NovelInfoHeader); const styles = StyleSheet.create({ novelDetails: { flex: 1, + flexDirection: 'column', paddingBottom: 16, paddingLeft: 12, justifyContent: 'center', @@ -217,6 +208,6 @@ const styles = StyleSheet.create({ paddingRight: 12, }, infoItem: { - marginVertical: 4, + marginVertical: 2, }, });