From dcb760283799f58e75c3d10813f0ab4f881ac546 Mon Sep 17 00:00:00 2001 From: Huang Xin Date: Sat, 21 Jun 2025 19:17:24 +0800 Subject: [PATCH] fix: importing books on iOS at first launch is more reliable now (#1439) --- apps/readest-app/src/app/error.tsx | 8 ++++---- .../src/app/library/components/BookItem.tsx | 4 ++++ apps/readest-app/src/app/library/page.tsx | 14 ++++++++------ apps/readest-app/src/hooks/useTheme.ts | 4 ++-- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/apps/readest-app/src/app/error.tsx b/apps/readest-app/src/app/error.tsx index 37886d14..c50d155c 100644 --- a/apps/readest-app/src/app/error.tsx +++ b/apps/readest-app/src/app/error.tsx @@ -36,8 +36,8 @@ export default function Error({ error, reset }: ErrorPageProps) { return (
-
-
+
+
⚠️
@@ -55,8 +55,8 @@ export default function Error({ error, reset }: ErrorPageProps) {

{error.message}

{browserInfo &&

Browser: {browserInfo}

} {error.stack && ( -

- {error.stack.split('\n').slice(0, 5).join('\n')} +

+ {error.stack.split('\n').slice(0, 3).join('\n')}

)} {error.digest &&

Error ID: {error.digest}

} diff --git a/apps/readest-app/src/app/library/components/BookItem.tsx b/apps/readest-app/src/app/library/components/BookItem.tsx index dd3850ca..14e499b5 100644 --- a/apps/readest-app/src/app/library/components/BookItem.tsx +++ b/apps/readest-app/src/app/library/components/BookItem.tsx @@ -102,6 +102,10 @@ const BookItem: React.FC = ({
{book.progress && }
diff --git a/apps/readest-app/src/app/library/page.tsx b/apps/readest-app/src/app/library/page.tsx index 9601542f..00962f9f 100644 --- a/apps/readest-app/src/app/library/page.tsx +++ b/apps/readest-app/src/app/library/page.tsx @@ -401,8 +401,14 @@ const LibraryPageContent = ({ searchParams }: { searchParams: ReadonlyURLSearchP }; const selectFilesTauri = async () => { - const exts = appService?.isAndroidApp ? [] : SUPPORTED_FILE_EXTS; + const exts = appService?.isMobileApp ? [] : SUPPORTED_FILE_EXTS; const files = (await appService?.selectFiles(_('Select Books'), exts)) || []; + if (appService?.isIOSApp) { + return files.filter((file) => { + const fileExt = file.split('.').pop()?.toLowerCase() || 'unknown'; + return SUPPORTED_FILE_EXTS.includes(fileExt); + }); + } // Cannot filter out files on Android since some content providers may not return the file name return files; }; @@ -525,11 +531,7 @@ const LibraryPageContent = ({ searchParams }: { searchParams: ReadonlyURLSearchP let files; if (isTauriAppPlatform()) { - if (appService?.isIOSApp) { - files = (await selectFilesWeb()) as [File]; - } else { - files = (await selectFilesTauri()) as [string]; - } + files = (await selectFilesTauri()) as [string]; } else { files = (await selectFilesWeb()) as [File]; } diff --git a/apps/readest-app/src/hooks/useTheme.ts b/apps/readest-app/src/hooks/useTheme.ts index 5dba107a..6adb393e 100644 --- a/apps/readest-app/src/hooks/useTheme.ts +++ b/apps/readest-app/src/hooks/useTheme.ts @@ -80,10 +80,10 @@ export const useTheme = ({ } }; document.addEventListener('visibilitychange', handleVisibilityChange); - screen.orientation.addEventListener('change', handleOrientationChange); + screen.orientation?.addEventListener('change', handleOrientationChange); return () => { document.removeEventListener('visibilitychange', handleVisibilityChange); - screen.orientation.removeEventListener('change', handleOrientationChange); + screen.orientation?.removeEventListener('change', handleOrientationChange); }; // eslint-disable-next-line react-hooks/exhaustive-deps }, [handleSystemUIVisibility]);