From c77dc52f2914d19efcee1763ee0e9128c1c167b5 Mon Sep 17 00:00:00 2001 From: Rajarshee Chatterjee Date: Sun, 28 Apr 2024 18:38:30 +0530 Subject: [PATCH] Tweak UX (#1052) * Tweak UX * Prevent Crash in Migrate Screen * Cleanup --- src/database/queries/ChapterQueries.ts | 7 ++-- src/database/queries/HistoryQueries.ts | 4 ++- .../hooks/useGlobalSearch.ts | 2 +- .../browse/migration/MigrationNovelList.tsx | 2 +- .../browse/migration/MigrationNovels.tsx | 2 +- src/screens/novel/components/ChapterItem.tsx | 18 ++++++++-- .../novel/components/EditInfoModal.tsx | 25 +++++++------ .../components/Info/NovelInfoComponents.tsx | 1 + .../novel/components/Info/NovelInfoHeader.tsx | 35 ++++++++++++------- .../updates/components/UpdateNovelCard.tsx | 28 +++------------ 10 files changed, 67 insertions(+), 57 deletions(-) diff --git a/src/database/queries/ChapterQueries.ts b/src/database/queries/ChapterQueries.ts index c63cc85e4..06f62a0a8 100644 --- a/src/database/queries/ChapterQueries.ts +++ b/src/database/queries/ChapterQueries.ts @@ -290,10 +290,9 @@ export const downloadChapter = async ( if (chapterText && chapterText.length) { await downloadFiles(chapterText, plugin, novelId, chapterId); db.transaction(tx => { - tx.executeSql( - "UPDATE Chapter SET isDownloaded = 1, updatedTime = datetime('now','localtime') WHERE id = ?", - [chapterId], - ); + tx.executeSql('UPDATE Chapter SET isDownloaded = 1 WHERE id = ?', [ + chapterId, + ]); }); } else { throw new Error(getString('downloadScreen.chapterEmptyOrScrapeError')); diff --git a/src/database/queries/HistoryQueries.ts b/src/database/queries/HistoryQueries.ts index abd9ad00b..8c2c818aa 100644 --- a/src/database/queries/HistoryQueries.ts +++ b/src/database/queries/HistoryQueries.ts @@ -9,10 +9,12 @@ import { getString } from '@strings/translations'; const getHistoryQuery = ` SELECT - Chapter.*, Novel.pluginId, Novel.name as novelName, Novel.path as novelPath, Novel.cover as novelCover + Chapter.*, Novel.pluginId, Novel.name as novelName, Novel.path as novelPath, Novel.cover as novelCover, Novel.id as novelId FROM Chapter JOIN Novel ON Chapter.novelId = Novel.id AND Chapter.readTime IS NOT NULL + GROUP BY novelId + HAVING readTime = MAX(readTime) ORDER BY readTime DESC `; diff --git a/src/screens/GlobalSearchScreen/hooks/useGlobalSearch.ts b/src/screens/GlobalSearchScreen/hooks/useGlobalSearch.ts index a93ebb001..195367ef2 100644 --- a/src/screens/GlobalSearchScreen/hooks/useGlobalSearch.ts +++ b/src/screens/GlobalSearchScreen/hooks/useGlobalSearch.ts @@ -77,7 +77,7 @@ export const useGlobalSearch = ({ defaultSearchText }: Props) => { ...prevResult, novels: [], isLoading: false, - error: error.message, + error: error?.message, } : { ...prevResult }, ), diff --git a/src/screens/browse/migration/MigrationNovelList.tsx b/src/screens/browse/migration/MigrationNovelList.tsx index 1c333b4e7..5a94124e2 100644 --- a/src/screens/browse/migration/MigrationNovelList.tsx +++ b/src/screens/browse/migration/MigrationNovelList.tsx @@ -105,7 +105,7 @@ const MigrationNovelList = ({ }} > {getString('browseScreen.migration.dialogMessage', { - url: selectedNovel.path, + url: selectedNovel.name, })} { ? { ...pluginItem, loading: false, - error: e.message, + error: e?.message, } : pluginItem, ), diff --git a/src/screens/novel/components/ChapterItem.tsx b/src/screens/novel/components/ChapterItem.tsx index 4e3c268ee..2791bccbf 100644 --- a/src/screens/novel/components/ChapterItem.tsx +++ b/src/screens/novel/components/ChapterItem.tsx @@ -83,7 +83,13 @@ const ChapterItem: React.FC = ({ {novelName} ) : null} - + {unread ? ( = ({ })} - + {releaseTime && !isUpdateCard ? ( = ({ : bookmark ? theme.primary : theme.onSurfaceVariant, + marginTop: 4, }, styles.text, ]} @@ -137,6 +149,7 @@ const ChapterItem: React.FC = ({ color: theme.outline, fontSize: 12, marginLeft: chapter.releaseTime ? 5 : 0, + marginTop: 4, }} numberOfLines={1} > @@ -179,7 +192,6 @@ const styles = StyleSheet.create({ }, textRow: { flexDirection: 'row', - marginTop: 5, }, row: { flex: 1, flexDirection: 'row', alignItems: 'center' }, unreadIcon: { diff --git a/src/screens/novel/components/EditInfoModal.tsx b/src/screens/novel/components/EditInfoModal.tsx index d3debe7c9..b2184f8a4 100644 --- a/src/screens/novel/components/EditInfoModal.tsx +++ b/src/screens/novel/components/EditInfoModal.tsx @@ -112,48 +112,47 @@ const EditInfoModal = ({ placeholder={getString('novelScreen.edit.title', { title: novel.name, })} - style={{ fontSize: 14 }} numberOfLines={1} mode="outlined" theme={{ colors: { ...theme } }} onChangeText={text => setNovel({ ...novel, name: text })} dense + style={styles.inputWrapper} /> setNovel({ ...novel, author: text })} dense + style={styles.inputWrapper} /> setNovel({ ...novel, artist: text })} dense + style={styles.inputWrapper} /> setNovel({ ...novel, summary: text })} theme={{ colors: { ...theme } }} dense + style={styles.inputWrapper} /> setTag(text)} @@ -163,6 +162,7 @@ const EditInfoModal = ({ }} theme={{ colors: { ...theme } }} dense + style={styles.inputWrapper} /> {novel.genres !== undefined && novel.genres !== '' ? ( @@ -213,11 +213,11 @@ const GenreChip = ({ borderRadius: 8, paddingVertical: 6, paddingHorizontal: 16, - marginVertical: 4, + marginBottom: 4, marginRight: 8, justifyContent: 'center', alignItems: 'center', - backgroundColor: theme.outline, + backgroundColor: theme.secondaryContainer, }} > void; } +const getStatusIcon = (status?: string) => { + if (status === NovelStatus.Ongoing) { + return 'clock-outline'; + } + if (status === NovelStatus.Completed) { + return 'check-all'; + } + return 'help'; +}; + const NovelInfoHeader = ({ novel, theme, @@ -69,15 +81,14 @@ const NovelInfoHeader = ({ }: NovelInfoHeaderProps) => { const { hideBackdrop = false } = useAppSettings(); - const getStatusIcon = useCallback((status?: string) => { - if (status === NovelStatus.Ongoing) { - return 'clock-outline'; - } - if (status === NovelStatus.Completed) { - return 'check-all'; - } - return 'help'; - }, []); + const pluginName = useMemo( + () => + (getMMKVObject(AVAILABLE_PLUGINS) || []).find( + plugin => plugin.id === novel.pluginId, + )?.name, + [], + ); + return ( <> diff --git a/src/screens/updates/components/UpdateNovelCard.tsx b/src/screens/updates/components/UpdateNovelCard.tsx index df10b69e1..36fda02bc 100644 --- a/src/screens/updates/components/UpdateNovelCard.tsx +++ b/src/screens/updates/components/UpdateNovelCard.tsx @@ -8,7 +8,6 @@ import { Update, } from '@database/types'; import { List } from 'react-native-paper'; -import { coverPlaceholderColor } from '@theme/colors'; import { NavigationProp, useNavigation } from '@react-navigation/native'; import ChapterItem from '@screens/novel/components/ChapterItem'; import { useDownload, useTheme } from '@hooks/persisted'; @@ -24,7 +23,7 @@ const NovelCover = ({ navigateToNovel: () => void; }) => { return ( - + ); @@ -106,6 +105,7 @@ const UpdateNovelCard: React.FC = ({ data={chapterList} keyExtractor={it => 'update' + it.id} extraData={[chapterList]} + style={styles.chapterList} renderItem={({ item }) => { return (