diff --git a/apps/readest-app/public/locales/ar/translation.json b/apps/readest-app/public/locales/ar/translation.json index fb846687..9b2fb5cd 100644 --- a/apps/readest-app/public/locales/ar/translation.json +++ b/apps/readest-app/public/locales/ar/translation.json @@ -8,7 +8,6 @@ "Auto Mode": "الوضع التلقائي", "Behavior": "السلوك", "Book": "الكتاب", - "Book Cover": "غلاف الكتاب", "Bookmark": "علامة مرجعية", "Cancel": "إلغاء", "Chapter": "الفصل", @@ -672,5 +671,6 @@ "Update email": "تحديث البريد الإلكتروني", "Current email": "البريد الإلكتروني الحالي", "Update Email": "تحديث البريد الإلكتروني", - "All": "الكل" + "All": "الكل", + "Unable to open book": "غير قادر على فتح الكتاب" } diff --git a/apps/readest-app/public/locales/bn/translation.json b/apps/readest-app/public/locales/bn/translation.json index fa330795..098ac5ec 100644 --- a/apps/readest-app/public/locales/bn/translation.json +++ b/apps/readest-app/public/locales/bn/translation.json @@ -302,7 +302,6 @@ "Link Color": "লিঙ্ক রঙ", "Preview": "প্রিভিউ", "Font & Layout": "ফন্ট ও লেআউট", - "Book Cover": "বইয়ের মলাট", "More Info": "আরো তথ্য", "Parallel Read": "সমান্তরাল পড়া", "Disable": "নিষ্ক্রিয়", @@ -656,5 +655,6 @@ "Update email": "ইমেল আপডেট করুন", "Current email": "বর্তমান ইমেল", "Update Email": "ইমেল আপডেট করুন", - "All": "সব" + "All": "সব", + "Unable to open book": "বই খুলতে অক্ষম" } diff --git a/apps/readest-app/public/locales/bo/translation.json b/apps/readest-app/public/locales/bo/translation.json index df7ead35..c8074ee2 100644 --- a/apps/readest-app/public/locales/bo/translation.json +++ b/apps/readest-app/public/locales/bo/translation.json @@ -8,7 +8,6 @@ "Auto Mode": "རང་འགུལ་བརྗོད་བྱ།", "Behavior": "བྱ་སྤྱོད།", "Book": "དཔེ་དེབ།", - "Book Cover": "དཔེ་དེབ་ཀྱི་སྟོང་ངོས།", "Bookmark": "དཔེ་རྟགས།", "Cancel": "འདོར་བ།", "Chapter": "ལེའུ།", @@ -652,5 +651,6 @@ "Update email": "ཡིག་འཕྲིན་གསར་བསྒྱུར།", "Current email": "མིག་སྔའི་ཡིག་འཕྲིན།", "Update Email": "ཡིག་འཕྲིན་གསར་བསྒྱུར།", - "All": "ཆེན་མོ།" + "All": "ཆེན་མོ།", + "Unable to open book": "དེབ་ཀྱི་སྤྱོད་བྱས་མ་ཐུབ།" } diff --git a/apps/readest-app/public/locales/de/translation.json b/apps/readest-app/public/locales/de/translation.json index 706583c5..5d460e88 100644 --- a/apps/readest-app/public/locales/de/translation.json +++ b/apps/readest-app/public/locales/de/translation.json @@ -8,7 +8,6 @@ "Auto Mode": "Automatischer Modus", "Behavior": "Verhalten", "Book": "Buch", - "Book Cover": "Buchcover", "Bookmark": "Lesezeichen", "Cancel": "Abbrechen", "Chapter": "Kapitel", @@ -656,5 +655,6 @@ "Update email": "E-Mail aktualisieren", "Current email": "Aktuelle E-Mail", "Update Email": "E-Mail aktualisieren", - "All": "Alle" + "All": "Alle", + "Unable to open book": "Buch kann nicht geöffnet werden" } diff --git a/apps/readest-app/public/locales/el/translation.json b/apps/readest-app/public/locales/el/translation.json index 58d787b7..d95ba07f 100644 --- a/apps/readest-app/public/locales/el/translation.json +++ b/apps/readest-app/public/locales/el/translation.json @@ -8,7 +8,6 @@ "Auto Mode": "Αυτόματη λειτουργία", "Behavior": "Συμπεριφορά", "Book": "Βιβλίο", - "Book Cover": "Εξώφυλλο βιβλίου", "Bookmark": "Σελιδοδείκτης", "Cancel": "Ακύρωση", "Chapter": "Κεφάλαιο", @@ -656,5 +655,6 @@ "Update email": "Ενημέρωση email", "Current email": "Τρέχον email", "Update Email": "Ενημέρωση email", - "All": "Όλα" + "All": "Όλα", + "Unable to open book": "Αδύνατη η άνοιγμα του βιβλίου" } diff --git a/apps/readest-app/public/locales/es/translation.json b/apps/readest-app/public/locales/es/translation.json index dff6b097..d2f0e46e 100644 --- a/apps/readest-app/public/locales/es/translation.json +++ b/apps/readest-app/public/locales/es/translation.json @@ -8,7 +8,6 @@ "Auto Mode": "Modo automático", "Behavior": "Comportamiento", "Book": "Libro", - "Book Cover": "Portada del libro", "Bookmark": "Marcador", "Cancel": "Cancelar", "Chapter": "Capítulo", @@ -660,5 +659,6 @@ "Update email": "Actualizar correo electrónico", "Current email": "Correo electrónico actual", "Update Email": "Actualizar correo electrónico", - "All": "Todos" + "All": "Todos", + "Unable to open book": "No se puede abrir el libro" } diff --git a/apps/readest-app/public/locales/fa/translation.json b/apps/readest-app/public/locales/fa/translation.json index 63971cec..260ac652 100644 --- a/apps/readest-app/public/locales/fa/translation.json +++ b/apps/readest-app/public/locales/fa/translation.json @@ -8,7 +8,6 @@ "Auto Mode": "حالت خودکار", "Behavior": "رفتار", "Book": "کتاب", - "Book Cover": "جلد کتاب", "Bookmark": "نشانک", "Cancel": "لغو", "Chapter": "فصل", @@ -656,5 +655,6 @@ "Update email": "به‌روزرسانی ایمیل", "Current email": "ایمیل فعلی", "Update Email": "به‌روزرسانی ایمیل", - "All": "همه" + "All": "همه", + "Unable to open book": "قادر به باز کردن کتاب نیست" } diff --git a/apps/readest-app/public/locales/fr/translation.json b/apps/readest-app/public/locales/fr/translation.json index f8cdee10..4a000055 100644 --- a/apps/readest-app/public/locales/fr/translation.json +++ b/apps/readest-app/public/locales/fr/translation.json @@ -8,7 +8,6 @@ "Auto Mode": "Mode automatique", "Behavior": "Comportement", "Book": "Livre", - "Book Cover": "Couverture du livre", "Bookmark": "Signet", "Cancel": "Annuler", "Chapter": "Chapitre", @@ -660,5 +659,6 @@ "Update email": "Mettre à jour l’e-mail", "Current email": "E-mail actuel", "Update Email": "Mettre à jour l’e-mail", - "All": "Tous" + "All": "Tous", + "Unable to open book": "Impossible d'ouvrir le livre" } diff --git a/apps/readest-app/public/locales/hi/translation.json b/apps/readest-app/public/locales/hi/translation.json index f926c49d..577ebed1 100644 --- a/apps/readest-app/public/locales/hi/translation.json +++ b/apps/readest-app/public/locales/hi/translation.json @@ -8,7 +8,6 @@ "Auto Mode": "स्वचालित मोड", "Behavior": "व्यवहार", "Book": "पुस्तक", - "Book Cover": "पुस्तक का कवर", "Bookmark": "बुकमार्क", "Cancel": "रद्द करें", "Chapter": "अध्याय", @@ -656,5 +655,6 @@ "Update email": "ईमेल अपडेट करें", "Current email": "वर्तमान ईमेल", "Update Email": "ईमेल अपडेट करें", - "All": "सभी" + "All": "सभी", + "Unable to open book": "पुस्तक खोलने में असमर्थ" } diff --git a/apps/readest-app/public/locales/id/translation.json b/apps/readest-app/public/locales/id/translation.json index 8d531eb2..95cf3592 100644 --- a/apps/readest-app/public/locales/id/translation.json +++ b/apps/readest-app/public/locales/id/translation.json @@ -8,7 +8,6 @@ "Auto Mode": "Mode Otomatis", "Behavior": "Perilaku", "Book": "Buku", - "Book Cover": "Sampul Buku", "Bookmark": "Penanda", "Cancel": "Batal", "Chapter": "Bab", @@ -652,5 +651,6 @@ "Update email": "Perbarui email", "Current email": "Email saat ini", "Update Email": "Perbarui email", - "All": "Semua" + "All": "Semua", + "Unable to open book": "Tidak dapat membuka buku" } diff --git a/apps/readest-app/public/locales/it/translation.json b/apps/readest-app/public/locales/it/translation.json index 75f1d316..18d24aa4 100644 --- a/apps/readest-app/public/locales/it/translation.json +++ b/apps/readest-app/public/locales/it/translation.json @@ -8,7 +8,6 @@ "Auto Mode": "Modalità automatica", "Behavior": "Comportamento", "Book": "Libro", - "Book Cover": "Copertina", "Bookmark": "Segnalibro", "Cancel": "Annulla", "Chapter": "Capitolo", @@ -660,5 +659,6 @@ "Update email": "Aggiorna email", "Current email": "Email attuale", "Update Email": "Aggiorna email", - "All": "Tutti" + "All": "Tutti", + "Unable to open book": "Impossibile aprire il libro" } diff --git a/apps/readest-app/public/locales/ja/translation.json b/apps/readest-app/public/locales/ja/translation.json index 13067776..307be0b5 100644 --- a/apps/readest-app/public/locales/ja/translation.json +++ b/apps/readest-app/public/locales/ja/translation.json @@ -8,7 +8,6 @@ "Auto Mode": "自動モード", "Behavior": "動作", "Book": "書籍", - "Book Cover": "表紙", "Bookmark": "ブックマーク", "Cancel": "キャンセル", "Chapter": "章", @@ -652,5 +651,6 @@ "Update email": "メールを更新", "Current email": "現在のメールアドレス", "Update Email": "メールを更新", - "All": "すべて" + "All": "すべて", + "Unable to open book": "本を開くことができません" } diff --git a/apps/readest-app/public/locales/ko/translation.json b/apps/readest-app/public/locales/ko/translation.json index faedf44f..4e1800b7 100644 --- a/apps/readest-app/public/locales/ko/translation.json +++ b/apps/readest-app/public/locales/ko/translation.json @@ -8,7 +8,6 @@ "Auto Mode": "자동 모드", "Behavior": "동작", "Book": "책", - "Book Cover": "책 표지", "Bookmark": "북마크", "Cancel": "취소", "Chapter": "챕터", @@ -652,5 +651,6 @@ "Update email": "이메일 업데이트", "Current email": "현재 이메일", "Update Email": "이메일 업데이트", - "All": "전체" + "All": "전체", + "Unable to open book": "책을 열 수 없습니다" } diff --git a/apps/readest-app/public/locales/nl/translation.json b/apps/readest-app/public/locales/nl/translation.json index 6d48cf6a..9cf5fad7 100644 --- a/apps/readest-app/public/locales/nl/translation.json +++ b/apps/readest-app/public/locales/nl/translation.json @@ -196,7 +196,6 @@ "Link Color": "Linkkleur", "Preview": "Voorbeeld", "Font & Layout": "Lettertype & opmaak", - "Book Cover": "Boekomslag", "More Info": "Meer informatie", "Parallel Read": "Parallel lezen", "Export Annotations": "Annotaties exporteren", @@ -656,5 +655,6 @@ "Update email": "E-mail bijwerken", "Current email": "Huidig e-mailadres", "Update Email": "E-mail bijwerken", - "All": "Alles" + "All": "Alles", + "Unable to open book": "Kan boek niet openen" } diff --git a/apps/readest-app/public/locales/pl/translation.json b/apps/readest-app/public/locales/pl/translation.json index 2a6d3c4a..e1d9d1b0 100644 --- a/apps/readest-app/public/locales/pl/translation.json +++ b/apps/readest-app/public/locales/pl/translation.json @@ -8,7 +8,6 @@ "Auto Mode": "Tryb automatyczny", "Behavior": "Zachowanie", "Book": "Książka", - "Book Cover": "Okładka książki", "Bookmark": "Zakładka", "Cancel": "Anuluj", "Chapter": "Rozdział", @@ -664,5 +663,6 @@ "Update email": "Zaktualizuj e-mail", "Current email": "Obecny e-mail", "Update Email": "Zaktualizuj e-mail", - "All": "Wszystkie" + "All": "Wszystkie", + "Unable to open book": "Nie można otworzyć książki" } diff --git a/apps/readest-app/public/locales/pt/translation.json b/apps/readest-app/public/locales/pt/translation.json index bc5f0984..1dd8ad49 100644 --- a/apps/readest-app/public/locales/pt/translation.json +++ b/apps/readest-app/public/locales/pt/translation.json @@ -8,7 +8,6 @@ "Auto Mode": "Modo Automático", "Behavior": "Comportamento", "Book": "Livro", - "Book Cover": "Capa do Livro", "Bookmark": "Marcador", "Cancel": "Cancelar", "Chapter": "Capítulo", @@ -660,5 +659,6 @@ "Update email": "Atualizar e-mail", "Current email": "E-mail atual", "Update Email": "Atualizar e-mail", - "All": "Todos" + "All": "Todos", + "Unable to open book": "Não foi possível abrir o livro" } diff --git a/apps/readest-app/public/locales/ru/translation.json b/apps/readest-app/public/locales/ru/translation.json index e92acc39..0f7bce44 100644 --- a/apps/readest-app/public/locales/ru/translation.json +++ b/apps/readest-app/public/locales/ru/translation.json @@ -8,7 +8,6 @@ "Auto Mode": "Автоматический режим", "Behavior": "Поведение", "Book": "Книга", - "Book Cover": "Обложка книги", "Bookmark": "Закладка", "Cancel": "Отмена", "Chapter": "Глава", @@ -664,5 +663,6 @@ "Update email": "Обновить электронную почту", "Current email": "Текущий адрес электронной почты", "Update Email": "Обновить электронную почту", - "All": "Все" + "All": "Все", + "Unable to open book": "Не удалось открыть книгу" } diff --git a/apps/readest-app/public/locales/si/translation.json b/apps/readest-app/public/locales/si/translation.json index 28b2d12b..98a4357d 100644 --- a/apps/readest-app/public/locales/si/translation.json +++ b/apps/readest-app/public/locales/si/translation.json @@ -302,7 +302,6 @@ "Link Color": "සබැඳි වර්ණය", "Preview": "පෙර දසුන", "Font & Layout": "අකුරු සහ පිරිසැලසුම", - "Book Cover": "පොත් ආවරණය", "More Info": "තවත් තොරතුරු", "Parallel Read": "සමාන්තර කියවීම", "Disable": "අබල කරන්න", @@ -656,5 +655,6 @@ "Update email": "විද්‍යුත් තැපැල් යාවත්කාලීන කරන්න", "Current email": "වත්මන් විද්‍යුත් තැපැල්", "Update Email": "විද්‍යුත් තැපැල් යාවත්කාලීන කරන්න", - "All": "සියල්ල" + "All": "සියල්ල", + "Unable to open book": "පොත විවෘත කිරීමට නොහැක" } diff --git a/apps/readest-app/public/locales/sv/translation.json b/apps/readest-app/public/locales/sv/translation.json index 187eab25..6d705bdb 100644 --- a/apps/readest-app/public/locales/sv/translation.json +++ b/apps/readest-app/public/locales/sv/translation.json @@ -241,7 +241,6 @@ "{{count}} pages left in chapter_other": "{{count}} sidor kvar i kapitlet", "On {{current}} of {{total}} page": "På {{current}} av {{total}} sidor", "Section Title": "Sektionstitel", - "Book Cover": "Bokomslag", "More Info": "Mer info", "Parallel Read": "Parallell läsning", "Disable": "Inaktivera", @@ -656,5 +655,6 @@ "Update email": "Uppdatera e-post", "Current email": "Nuvarande e-post", "Update Email": "Uppdatera e-post", - "All": "Alla" + "All": "Alla", + "Unable to open book": "Kunde inte öppna bok" } diff --git a/apps/readest-app/public/locales/ta/translation.json b/apps/readest-app/public/locales/ta/translation.json index 7c84e644..11102189 100644 --- a/apps/readest-app/public/locales/ta/translation.json +++ b/apps/readest-app/public/locales/ta/translation.json @@ -302,7 +302,6 @@ "Link Color": "இணைப்பு நிறம்", "Preview": "முன்னோட்டம்", "Font & Layout": "எழுத்துரு மற்றும் அமைப்பு", - "Book Cover": "புத்தக அட்டை", "More Info": "மேலும் தகவல்", "Parallel Read": "இணை வாசிப்பு", "Disable": "முடக்கவும்", @@ -656,5 +655,6 @@ "Update email": "மின்னஞ்சல் புதுப்பிக்கவும்", "Current email": "தற்போதைய மின்னஞ்சல்", "Update Email": "மின்னஞ்சல் புதுப்பிக்கவும்", - "All": "அனைத்து" + "All": "அனைத்து", + "Unable to open book": "புத்தகத்தைத் திறக்க முடியவில்லை" } diff --git a/apps/readest-app/public/locales/th/translation.json b/apps/readest-app/public/locales/th/translation.json index f866edb8..c4c5f8e4 100644 --- a/apps/readest-app/public/locales/th/translation.json +++ b/apps/readest-app/public/locales/th/translation.json @@ -255,7 +255,6 @@ "Link Color": "สีลิงก์", "Preview": "ดูตัวอย่าง", "Font & Layout": "ฟอนต์และเลย์เอาต์", - "Book Cover": "ปกหนังสือ", "More Info": "ข้อมูลเพิ่มเติม", "Parallel Read": "อ่านคู่ขนาน", "Disable": "ปิด", @@ -652,5 +651,6 @@ "Update email": "อัปเดตอีเมล", "Current email": "อีเมลปัจจุบัน", "Update Email": "อัปเดตอีเมล", - "All": "ทั้งหมด" + "All": "ทั้งหมด", + "Unable to open book": "ไม่สามารถเปิดหนังสือได้" } diff --git a/apps/readest-app/public/locales/tr/translation.json b/apps/readest-app/public/locales/tr/translation.json index c5d3c1c2..6daead42 100644 --- a/apps/readest-app/public/locales/tr/translation.json +++ b/apps/readest-app/public/locales/tr/translation.json @@ -8,7 +8,6 @@ "Auto Mode": "Otomatik Mod", "Behavior": "Davranış", "Book": "Kitap", - "Book Cover": "Kitap Kapağı", "Bookmark": "Yer İmi", "Cancel": "İptal", "Chapter": "Bölüm", @@ -656,5 +655,6 @@ "Update email": "E-postayı güncelle", "Current email": "Mevcut e-posta", "Update Email": "E-postayı güncelle", - "All": "Tümü" + "All": "Tümü", + "Unable to open book": "Kitap açılamıyor" } diff --git a/apps/readest-app/public/locales/uk/translation.json b/apps/readest-app/public/locales/uk/translation.json index 070a3683..658fcbd4 100644 --- a/apps/readest-app/public/locales/uk/translation.json +++ b/apps/readest-app/public/locales/uk/translation.json @@ -8,7 +8,6 @@ "Auto Mode": "Автоматичний режим", "Behavior": "Поведінка", "Book": "Книга", - "Book Cover": "Обкладинка книги", "Bookmark": "Закладка", "Cancel": "Скасувати", "Chapter": "Розділ", @@ -664,5 +663,6 @@ "Update email": "Оновити електронну пошту", "Current email": "Поточна електронна пошта", "Update Email": "Оновити електронну пошту", - "All": "Всі" + "All": "Всі", + "Unable to open book": "Не вдалося відкрити книгу" } diff --git a/apps/readest-app/public/locales/vi/translation.json b/apps/readest-app/public/locales/vi/translation.json index 04009712..9871a7c7 100644 --- a/apps/readest-app/public/locales/vi/translation.json +++ b/apps/readest-app/public/locales/vi/translation.json @@ -8,7 +8,6 @@ "Auto Mode": "Chế độ tự động", "Behavior": "Hành vi", "Book": "Sách", - "Book Cover": "Bìa sách", "Bookmark": "Đánh dấu", "Cancel": "Hủy", "Chapter": "Chương", @@ -652,5 +651,6 @@ "Update email": "Cập nhật email", "Current email": "Email hiện tại", "Update Email": "Cập nhật email", - "All": "Tất cả" + "All": "Tất cả", + "Unable to open book": "Không thể mở sách" } diff --git a/apps/readest-app/public/locales/zh-CN/translation.json b/apps/readest-app/public/locales/zh-CN/translation.json index 0f477d3b..eb2599a9 100644 --- a/apps/readest-app/public/locales/zh-CN/translation.json +++ b/apps/readest-app/public/locales/zh-CN/translation.json @@ -8,7 +8,6 @@ "Auto Mode": "自动主题", "Behavior": "行为", "Book": "书籍", - "Book Cover": "书籍封面", "Bookmark": "书签", "Cancel": "取消", "Chapter": "章节", @@ -652,5 +651,6 @@ "Update email": "更新邮箱", "Current email": "当前邮箱", "Update Email": "更新邮箱", - "All": "全部" + "All": "全部", + "Unable to open book": "无法打开书籍" } diff --git a/apps/readest-app/public/locales/zh-TW/translation.json b/apps/readest-app/public/locales/zh-TW/translation.json index b9989c43..d088ccb3 100644 --- a/apps/readest-app/public/locales/zh-TW/translation.json +++ b/apps/readest-app/public/locales/zh-TW/translation.json @@ -8,7 +8,6 @@ "Auto Mode": "自動主題", "Behavior": "行為", "Book": "書籍", - "Book Cover": "書籍封面", "Bookmark": "書籤", "Cancel": "取消", "Chapter": "章節", @@ -652,5 +651,6 @@ "Update email": "更新電子郵件", "Current email": "當前電子郵件", "Update Email": "更新電子郵件", - "All": "全部" + "All": "全部", + "Unable to open book": "無法打開書籍" } diff --git a/apps/readest-app/src/app/library/hooks/useBooksSync.ts b/apps/readest-app/src/app/library/hooks/useBooksSync.ts index dc5b401d..8ba38e39 100644 --- a/apps/readest-app/src/app/library/hooks/useBooksSync.ts +++ b/apps/readest-app/src/app/library/hooks/useBooksSync.ts @@ -129,22 +129,22 @@ export const useBooksSync = () => { if (newBooks.length > 0) { setIsSyncing(true); } - - const batchSize = 10; - for (let i = 0; i < newBooks.length; i += batchSize) { - const batch = newBooks.slice(i, i + batchSize); - await appService?.downloadBookCovers(batch); - await Promise.all(batch.map(processNewBook)); - const progress = Math.min((i + batchSize) / newBooks.length, 1); - setLibrary([...updatedLibrary]); - setSyncProgress(progress); - } - - setLibrary(updatedLibrary); - appService?.saveLibraryBooks(updatedLibrary); - - if (newBooks.length > 0) { - setIsSyncing(false); + try { + const batchSize = 10; + for (let i = 0; i < newBooks.length; i += batchSize) { + const batch = newBooks.slice(i, i + batchSize); + await appService?.downloadBookCovers(batch); + await Promise.all(batch.map(processNewBook)); + const progress = Math.min((i + batchSize) / newBooks.length, 1); + setLibrary([...updatedLibrary]); + setSyncProgress(progress); + } + setLibrary(updatedLibrary); + appService?.saveLibraryBooks(updatedLibrary); + } finally { + if (newBooks.length > 0) { + setIsSyncing(false); + } } }; diff --git a/apps/readest-app/src/app/reader/components/ReaderContent.tsx b/apps/readest-app/src/app/reader/components/ReaderContent.tsx index a1c07409..d56d17d7 100644 --- a/apps/readest-app/src/app/reader/components/ReaderContent.tsx +++ b/apps/readest-app/src/app/reader/components/ReaderContent.tsx @@ -9,6 +9,7 @@ import { useSettingsStore } from '@/store/settingsStore'; import { useBookDataStore } from '@/store/bookDataStore'; import { useReaderStore } from '@/store/readerStore'; import { useSidebarStore } from '@/store/sidebarStore'; +import { useTranslation } from '@/hooks/useTranslation'; import { SystemSettings } from '@/types/settings'; import { parseOpenWithFiles } from '@/helpers/openWith'; import { getCurrentWindow } from '@tauri-apps/api/window'; @@ -30,6 +31,7 @@ import Notebook from './notebook/Notebook'; import BooksGrid from './BooksGrid'; const ReaderContent: React.FC<{ ids?: string; settings: SystemSettings }> = ({ ids, settings }) => { + const _ = useTranslation(); const router = useRouter(); const searchParams = useSearchParams(); const { envConfig, appService } = useEnv(); @@ -42,6 +44,7 @@ const ReaderContent: React.FC<{ ids?: string; settings: SystemSettings }> = ({ i const [showDetailsBook, setShowDetailsBook] = useState(null); const isInitiating = useRef(false); const [loading, setLoading] = useState(false); + const [errorLoading, setErrorLoading] = useState(false); useBookShortcuts({ sideBarBookKey, bookKeys }); @@ -62,6 +65,13 @@ const ReaderContent: React.FC<{ ids?: string; settings: SystemSettings }> = ({ i if (!getViewState(key)) { initViewState(envConfig, id, key, isPrimary).catch((error) => { console.log('Error initializing book', key, error); + setErrorLoading(true); + eventDispatcher.dispatch('toast', { + message: _('Unable to open book'), + callback: () => navigateBackToLibrary(), + timeout: 2000, + type: 'error', + }); }); if (index === 0) setSideBarBookKey(key); } @@ -188,7 +198,8 @@ const ReaderContent: React.FC<{ ids?: string; settings: SystemSettings }> = ({ i if (!bookData || !bookData.book || !bookData.bookDoc || !viewSettings) { setTimeout(() => setLoading(true), 200); return ( - loading && ( + loading && + !errorLoading && (
diff --git a/apps/readest-app/src/components/Toast.tsx b/apps/readest-app/src/components/Toast.tsx index 4075e666..36a8ecd7 100644 --- a/apps/readest-app/src/components/Toast.tsx +++ b/apps/readest-app/src/components/Toast.tsx @@ -11,6 +11,7 @@ export const Toast = () => { const [toastType, setToastType] = useState('info'); const [toastTimeout, setToastTimeout] = useState(5000); const [messageClass, setMessageClass] = useState(''); + const [isVisible, setIsVisible] = useState(false); const toastDismissTimeout = useRef | null>(null); const toastClassMap = { @@ -22,26 +23,81 @@ export const Toast = () => { const alertClassMap = { info: 'alert-primary border-base-300', - success: 'alert-success border-0', - warning: 'alert-warning border-0', - error: 'alert-error border-0', + success: 'alert-success border-0 bg-gradient-to-r from-green-500 to-emerald-500', + warning: 'alert-warning border-0 bg-gradient-to-r from-amber-500 to-orange-500', + error: 'alert-error border-0 bg-gradient-to-r from-red-500 to-rose-500', + }; + + const iconMap = { + info: ( + + + + ), + success: ( + + + + ), + warning: ( + + + + ), + error: ( + + + + ), }; useEffect(() => { - if (toastDismissTimeout.current) clearTimeout(toastDismissTimeout.current); - const timeout = setTimeout(() => setToastMessage(''), toastTimeout); - toastDismissTimeout.current = timeout; + if (toastMessage) { + setTimeout(() => { + setIsVisible(true); + }, 0); + } + }, [toastMessage]); - return () => { - if (timeout) clearTimeout(timeout); - }; + useEffect(() => { + if (toastDismissTimeout.current) clearTimeout(toastDismissTimeout.current); + if (toastMessage) { + const timeout = setTimeout(() => { + setIsVisible(false); + setTimeout(() => setToastMessage(''), 300); + }, toastTimeout); + toastDismissTimeout.current = timeout; + return () => { + if (timeout) clearTimeout(timeout); + }; + } + return; }, [toastMessage, toastTimeout]); const handleShowToast = async (event: CustomEvent) => { - const { message, type = 'info', timeout, className = '' } = event.detail; + const { message, type = 'info', timeout, className = '', callback = null } = event.detail; setToastMessage(message); setToastType(type); if (timeout) setToastTimeout(timeout); + if (callback && typeof callback === 'function') { + setTimeout(() => callback(), timeout || 5000); + } setMessageClass(className); }; @@ -52,12 +108,19 @@ export const Toast = () => { }; }, []); + const handleDismiss = () => { + setIsVisible(false); + setTimeout(() => setToastMessage(''), 300); + if (toastDismissTimeout.current) clearTimeout(toastDismissTimeout.current); + }; + return ( toastMessage && (
{ : undefined, }} > -
+
+ {/* Icon */} +
{iconMap[toastType]}
+ + {/* Message */} { {toastMessage.split('\n').map((line, idx) => ( {line || <> } -
+ {idx < toastMessage.split('\n').length - 1 &&
}
))}
+ + {/* Close button */} +
) diff --git a/apps/readest-app/src/store/readerStore.ts b/apps/readest-app/src/store/readerStore.ts index d359edf5..e897c602 100644 --- a/apps/readest-app/src/store/readerStore.ts +++ b/apps/readest-app/src/store/readerStore.ts @@ -231,6 +231,7 @@ export const useReaderStore = create((set, get) => ({ }, }, })); + throw error; } }, getViewSettings: (key: string) => get().viewStates[key]?.viewSettings || null,