From 0a13f36e334f660624b5dd8ac577f02fa05c1239 Mon Sep 17 00:00:00 2001 From: Huang Xin Date: Wed, 5 Feb 2025 15:48:59 +0100 Subject: [PATCH] sync: add toast error for failed uploading when the cloud quota is insufficient (#299) --- .../public/locales/de/translation.json | 3 ++- .../public/locales/el/translation.json | 3 ++- .../public/locales/es/translation.json | 3 ++- .../public/locales/fr/translation.json | 3 ++- .../public/locales/hi/translation.json | 3 ++- .../public/locales/id/translation.json | 3 ++- .../public/locales/it/translation.json | 3 ++- .../public/locales/ja/translation.json | 3 ++- .../public/locales/ko/translation.json | 3 ++- .../public/locales/pl/translation.json | 3 ++- .../public/locales/pt/translation.json | 3 ++- .../public/locales/ru/translation.json | 3 ++- .../public/locales/tr/translation.json | 3 ++- .../public/locales/uk/translation.json | 3 ++- .../public/locales/vi/translation.json | 3 ++- .../public/locales/zh-CN/translation.json | 3 ++- .../public/locales/zh-TW/translation.json | 3 ++- apps/readest-app/src/app/library/page.tsx | 16 ++++++++++++++-- apps/readest-app/src/libs/storage.ts | 3 +++ 19 files changed, 51 insertions(+), 19 deletions(-) diff --git a/apps/readest-app/public/locales/de/translation.json b/apps/readest-app/public/locales/de/translation.json index d90a1920..bfe0250b 100644 --- a/apps/readest-app/public/locales/de/translation.json +++ b/apps/readest-app/public/locales/de/translation.json @@ -149,5 +149,6 @@ "Storage": "Speicher", "Book deleted: {{title}}": "Buch gelöscht: {{title}}", "Failed to delete book: {{title}}": "Fehler beim Löschen des Buches: {{title}}", - "Check Updates on Start": "Aktualisierungen beim Start prüfen" + "Check Updates on Start": "Aktualisierungen beim Start prüfen", + "Insufficient storage quota": "Unzureichendes Speicherkontingent" } diff --git a/apps/readest-app/public/locales/el/translation.json b/apps/readest-app/public/locales/el/translation.json index 50525193..c2eb4693 100644 --- a/apps/readest-app/public/locales/el/translation.json +++ b/apps/readest-app/public/locales/el/translation.json @@ -149,5 +149,6 @@ "Storage": "Αποθήκευση", "Book deleted: {{title}}": "Το βιβλίο με τίτλο {{title}} διαγράφηκε", "Failed to delete book: {{title}}": "Αποτυχία διαγραφής βιβλίου: {{title}}", - "Check Updates on Start": "Έλεγχος ενημερώσεων κατά την εκκίνηση" + "Check Updates on Start": "Έλεγχος ενημερώσεων κατά την εκκίνηση", + "Insufficient storage quota": "Ανεπαρκές όριο αποθήκευσης" } diff --git a/apps/readest-app/public/locales/es/translation.json b/apps/readest-app/public/locales/es/translation.json index 431d87ef..ad4cacfb 100644 --- a/apps/readest-app/public/locales/es/translation.json +++ b/apps/readest-app/public/locales/es/translation.json @@ -149,5 +149,6 @@ "Storage": "Almacenamiento", "Book deleted: {{title}}": "Libro eliminado: {{title}}", "Failed to delete book: {{title}}": "Error al eliminar libro: {{title}}", - "Check Updates on Start": "Comprobar actualizaciones al iniciar" + "Check Updates on Start": "Comprobar actualizaciones al iniciar", + "Insufficient storage quota": "Cuota de almacenamiento insuficiente" } diff --git a/apps/readest-app/public/locales/fr/translation.json b/apps/readest-app/public/locales/fr/translation.json index 555ffa5e..6d697931 100644 --- a/apps/readest-app/public/locales/fr/translation.json +++ b/apps/readest-app/public/locales/fr/translation.json @@ -149,5 +149,6 @@ "Storage": "Stockage", "Book deleted: {{title}}": "Livre supprimé : {{title}}", "Failed to delete book: {{title}}": "Échec de la suppression du livre : {{title}}", - "Check Updates on Start": "Vérifier les mises à jour au démarrage" + "Check Updates on Start": "Vérifier les mises à jour au démarrage", + "Insufficient storage quota": "Quota de stockage insuffisant" } diff --git a/apps/readest-app/public/locales/hi/translation.json b/apps/readest-app/public/locales/hi/translation.json index 1efe08a9..d2f164e2 100644 --- a/apps/readest-app/public/locales/hi/translation.json +++ b/apps/readest-app/public/locales/hi/translation.json @@ -149,5 +149,6 @@ "Storage": "स्टोरेज", "Book deleted: {{title}}": "पुस्तक हटाई गई: {{title}}", "Failed to delete book: {{title}}": "पुस्तक हटाने में विफल: {{title}}", - "Check Updates on Start": "शुरू में अपडेट जांचें" + "Check Updates on Start": "शुरू में अपडेट जांचें", + "Insufficient storage quota": "अपर्याप्त स्टोरेज कोटा" } diff --git a/apps/readest-app/public/locales/id/translation.json b/apps/readest-app/public/locales/id/translation.json index 216d8d88..afd7c2aa 100644 --- a/apps/readest-app/public/locales/id/translation.json +++ b/apps/readest-app/public/locales/id/translation.json @@ -149,5 +149,6 @@ "Storage": "Penyimpanan", "Book deleted: {{title}}": "Buku dihapus: {{title}}", "Failed to delete book: {{title}}": "Gagal menghapus buku: {{title}}", - "Check Updates on Start": "Periksa Pembaruan saat Memulai" + "Check Updates on Start": "Periksa Pembaruan saat Memulai", + "Insufficient storage quota": "Kuota penyimpanan tidak mencukupi" } diff --git a/apps/readest-app/public/locales/it/translation.json b/apps/readest-app/public/locales/it/translation.json index e6e1dc66..332f78f7 100644 --- a/apps/readest-app/public/locales/it/translation.json +++ b/apps/readest-app/public/locales/it/translation.json @@ -149,5 +149,6 @@ "Storage": "Archiviazione", "Book deleted: {{title}}": "Libro eliminato: {{title}}", "Failed to delete book: {{title}}": "Eliminazione libro non riuscita: {{title}}", - "Check Updates on Start": "Controlla aggiornamenti all'avvio" + "Check Updates on Start": "Controlla aggiornamenti all'avvio", + "Insufficient storage quota": "Quota di archiviazione insufficiente" } diff --git a/apps/readest-app/public/locales/ja/translation.json b/apps/readest-app/public/locales/ja/translation.json index e48fd4ab..aaebe380 100644 --- a/apps/readest-app/public/locales/ja/translation.json +++ b/apps/readest-app/public/locales/ja/translation.json @@ -149,5 +149,6 @@ "Storage": "ストレージ", "Book deleted: {{title}}": "書籍が削除されました:{{title}}", "Failed to delete book: {{title}}": "書籍の削除に失敗しました:{{title}}", - "Check Updates on Start": "開始時に更新を確認" + "Check Updates on Start": "開始時に更新を確認", + "Insufficient storage quota": "ストレージクォータが不足しています" } diff --git a/apps/readest-app/public/locales/ko/translation.json b/apps/readest-app/public/locales/ko/translation.json index 345adc83..b49b9116 100644 --- a/apps/readest-app/public/locales/ko/translation.json +++ b/apps/readest-app/public/locales/ko/translation.json @@ -149,5 +149,6 @@ "Storage": "저장소", "Book deleted: {{title}}": "책 삭제됨: {{title}}", "Failed to delete book: {{title}}": "책 삭제 실패: {{title}}", - "Check Updates on Start": "시작 시 업데이트 확인" + "Check Updates on Start": "시작 시 업데이트 확인", + "Insufficient storage quota": "저장소 할당량 부족" } diff --git a/apps/readest-app/public/locales/pl/translation.json b/apps/readest-app/public/locales/pl/translation.json index 8623e707..dec71672 100644 --- a/apps/readest-app/public/locales/pl/translation.json +++ b/apps/readest-app/public/locales/pl/translation.json @@ -149,5 +149,6 @@ "Storage": "Przechowywanie", "Book deleted: {{title}}": "Książka usunięta: {{title}}", "Failed to delete book: {{title}}": "Nie udało się usunąć książki: {{title}}", - "Check Updates on Start": "Sprawdź aktualizacje przy starcie" + "Check Updates on Start": "Sprawdź aktualizacje przy starcie", + "Insufficient storage quota": "Niewystarczająca kwota przechowywania" } diff --git a/apps/readest-app/public/locales/pt/translation.json b/apps/readest-app/public/locales/pt/translation.json index a5bdc5a7..7f6fe141 100644 --- a/apps/readest-app/public/locales/pt/translation.json +++ b/apps/readest-app/public/locales/pt/translation.json @@ -149,5 +149,6 @@ "Storage": "Armazenamento", "Book deleted: {{title}}": "Livro excluído: {{title}}", "Failed to delete book: {{title}}": "Falha ao excluir livro: {{title}}", - "Check Updates on Start": "Verificar Atualizações ao Iniciar" + "Check Updates on Start": "Verificar Atualizações ao Iniciar", + "Insufficient storage quota": "Cota de armazenamento insuficiente" } diff --git a/apps/readest-app/public/locales/ru/translation.json b/apps/readest-app/public/locales/ru/translation.json index b7df49f5..e0c21dd1 100644 --- a/apps/readest-app/public/locales/ru/translation.json +++ b/apps/readest-app/public/locales/ru/translation.json @@ -149,5 +149,6 @@ "Storage": "Хранилище", "Book deleted: {{title}}": "Книга удалена: {{title}}", "Failed to delete book: {{title}}": "Не удалось удалить книгу: {{title}}", - "Check Updates on Start": "Проверять обновления при запуске" + "Check Updates on Start": "Проверять обновления при запуске", + "Insufficient storage quota": "Недостаточно квоты хранилища" } diff --git a/apps/readest-app/public/locales/tr/translation.json b/apps/readest-app/public/locales/tr/translation.json index 8c532df5..6ef4c736 100644 --- a/apps/readest-app/public/locales/tr/translation.json +++ b/apps/readest-app/public/locales/tr/translation.json @@ -149,5 +149,6 @@ "Storage": "Depolama", "Book deleted: {{title}}": "Kitap silindi: {{title}}", "Failed to delete book: {{title}}": "Kitap silinemedi: {{title}}", - "Check Updates on Start": "Başlangıçta Güncellemeleri Kontrol Et" + "Check Updates on Start": "Başlangıçta Güncellemeleri Kontrol Et", + "Insufficient storage quota": "Yetersiz depolama kotası" } diff --git a/apps/readest-app/public/locales/uk/translation.json b/apps/readest-app/public/locales/uk/translation.json index 0b48a9cd..818355c3 100644 --- a/apps/readest-app/public/locales/uk/translation.json +++ b/apps/readest-app/public/locales/uk/translation.json @@ -149,5 +149,6 @@ "Storage": "Сховище", "Book deleted: {{title}}": "Книгу видалено: {{title}}", "Failed to delete book: {{title}}": "Не вдалося видалити книгу: {{title}}", - "Check Updates on Start": "Перевіряти оновлення при запуску" + "Check Updates on Start": "Перевіряти оновлення при запуску", + "Insufficient storage quota": "Недостатньо квоти сховища" } diff --git a/apps/readest-app/public/locales/vi/translation.json b/apps/readest-app/public/locales/vi/translation.json index c0db0c3b..0392e387 100644 --- a/apps/readest-app/public/locales/vi/translation.json +++ b/apps/readest-app/public/locales/vi/translation.json @@ -149,5 +149,6 @@ "Storage": "Lưu trữ", "Book deleted: {{title}}": "Sách đã xóa: {{title}}", "Failed to delete book: {{title}}": "Không thể xóa sách: {{title}}", - "Check Updates on Start": "Kiểm tra cập nhật khi khởi động" + "Check Updates on Start": "Kiểm tra cập nhật khi khởi động", + "Insufficient storage quota": "Không đủ lượng lưu trữ" } diff --git a/apps/readest-app/public/locales/zh-CN/translation.json b/apps/readest-app/public/locales/zh-CN/translation.json index e12d7759..e14a7c43 100644 --- a/apps/readest-app/public/locales/zh-CN/translation.json +++ b/apps/readest-app/public/locales/zh-CN/translation.json @@ -149,5 +149,6 @@ "Storage": "存储空间", "Book deleted: {{title}}": "书籍已删除:{{title}}", "Failed to delete book: {{title}}": "删除书籍失败:{{title}}", - "Check Updates on Start": "启动时检查更新" + "Check Updates on Start": "启动时检查更新", + "Insufficient storage quota": "云存储空间不足" } diff --git a/apps/readest-app/public/locales/zh-TW/translation.json b/apps/readest-app/public/locales/zh-TW/translation.json index 18faa180..138c50a1 100644 --- a/apps/readest-app/public/locales/zh-TW/translation.json +++ b/apps/readest-app/public/locales/zh-TW/translation.json @@ -149,5 +149,6 @@ "Storage": "存儲空間", "Book deleted: {{title}}": "書籍已刪除:{{title}}", "Failed to delete book: {{title}}": "書籍刪除失敗:{{title}}", - "Check Updates on Start": "啟動時檢查更新" + "Check Updates on Start": "啟動時檢查更新", + "Insufficient storage quota": "雲存儲空間不足" } diff --git a/apps/readest-app/src/app/library/page.tsx b/apps/readest-app/src/app/library/page.tsx index 4f3b7258..59c46087 100644 --- a/apps/readest-app/src/app/library/page.tsx +++ b/apps/readest-app/src/app/library/page.tsx @@ -7,7 +7,7 @@ import { useRouter } from 'next/navigation'; import { Book } from '@/types/book'; import { AppService } from '@/types/system'; -import { navigateToReader } from '@/utils/nav'; +import { navigateToLogin, navigateToReader } from '@/utils/nav'; import { getBaseFilename, listFormater } from '@/utils/book'; import { eventDispatcher } from '@/utils/event'; import { parseOpenWithFiles } from '@/helpers/cli'; @@ -244,7 +244,19 @@ const LibraryPage = () => { title: book.title, }), }); - } catch { + } catch (err) { + if (err instanceof Error) { + if (err.message.includes('Not authenticated')) { + navigateToLogin(router); + return; + } else if (err.message.includes('Insufficient storage quota')) { + eventDispatcher.dispatch('toast', { + type: 'error', + message: _('Insufficient storage quota'), + }); + return; + } + } eventDispatcher.dispatch('toast', { type: 'error', message: _('Failed to upload book: {{title}}', { diff --git a/apps/readest-app/src/libs/storage.ts b/apps/readest-app/src/libs/storage.ts index 3a6f242c..4291b576 100644 --- a/apps/readest-app/src/libs/storage.ts +++ b/apps/readest-app/src/libs/storage.ts @@ -82,6 +82,9 @@ export const uploadFile = async ( } } catch (error) { console.error('File upload failed:', error); + if (error instanceof Error) { + throw error; + } throw new Error('File upload failed'); } };