From 11bc7497e8e2f773111ea522b68db81222693741 Mon Sep 17 00:00:00 2001 From: Huang Xin Date: Sun, 7 Dec 2025 17:04:23 +0800 Subject: [PATCH] feat: add support for renaming bookshelf groups (#2639) --- .../public/locales/ar/translation.json | 3 +- .../public/locales/bn/translation.json | 3 +- .../public/locales/bo/translation.json | 3 +- .../public/locales/de/translation.json | 3 +- .../public/locales/el/translation.json | 3 +- .../public/locales/es/translation.json | 3 +- .../public/locales/fa/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/ms/translation.json | 3 +- .../public/locales/nl/translation.json | 3 +- .../public/locales/pl/translation.json | 3 +- .../public/locales/pt/translation.json | 3 +- .../public/locales/ru/translation.json | 3 +- .../public/locales/si/translation.json | 3 +- .../public/locales/sv/translation.json | 3 +- .../public/locales/ta/translation.json | 3 +- .../public/locales/th/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 +- .../app/library/components/GroupingModal.tsx | 113 ++++++++++++++---- apps/readest-app/src/store/libraryStore.ts | 15 +-- 29 files changed, 146 insertions(+), 63 deletions(-) diff --git a/apps/readest-app/public/locales/ar/translation.json b/apps/readest-app/public/locales/ar/translation.json index ce772fb7..6760e4d1 100644 --- a/apps/readest-app/public/locales/ar/translation.json +++ b/apps/readest-app/public/locales/ar/translation.json @@ -795,5 +795,6 @@ "Are you sure to delete {{count}} selected file(s)?_few": "هل أنت متأكد من حذف {{count}} ملفات محددة؟", "Are you sure to delete {{count}} selected file(s)?_many": "هل أنت متأكد من حذف {{count}} ملفًا محددًا؟", "Are you sure to delete {{count}} selected file(s)?_other": "هل أنت متأكد من حذف {{count}} ملف محدد؟", - "Cloud Storage Usage": "استخدام التخزين السحابي" + "Cloud Storage Usage": "استخدام التخزين السحابي", + "Rename Group": "إعادة تسمية المجموعة" } diff --git a/apps/readest-app/public/locales/bn/translation.json b/apps/readest-app/public/locales/bn/translation.json index 1007a9da..42d209aa 100644 --- a/apps/readest-app/public/locales/bn/translation.json +++ b/apps/readest-app/public/locales/bn/translation.json @@ -759,5 +759,6 @@ "Page {{current}} of {{total}}": "{{total}}টির মধ্যে {{current}} পৃষ্ঠা", "Are you sure to delete {{count}} selected file(s)?_one": "আপনি কি নিশ্চিত যে {{count}}টি নির্বাচিত ফাইল মুছতে চান?", "Are you sure to delete {{count}} selected file(s)?_other": "আপনি কি নিশ্চিত যে {{count}}টি নির্বাচিত ফাইল মুছতে চান?", - "Cloud Storage Usage": "ক্লাউড স্টোরেজ ব্যবহৃত" + "Cloud Storage Usage": "ক্লাউড স্টোরেজ ব্যবহৃত", + "Rename Group": "গ্রুপের নাম পরিবর্তন করুন" } diff --git a/apps/readest-app/public/locales/bo/translation.json b/apps/readest-app/public/locales/bo/translation.json index f53dc612..f05fddbf 100644 --- a/apps/readest-app/public/locales/bo/translation.json +++ b/apps/readest-app/public/locales/bo/translation.json @@ -750,5 +750,6 @@ "files": "ཡིག་ཆ", "Page {{current}} of {{total}}": "ཤོག་ངོས་ {{total}} ནས་ {{current}}", "Are you sure to delete {{count}} selected file(s)?_other": "ཁྱེད་ཀྱིས་འདེམས་པའི་ཡིག་ཆ་ {{count}} བསུབས་དགོས་པ་ངེས་ཡིན་ན?", - "Cloud Storage Usage": "སྤྲིན་གནས་སྣོད་གསོག་ལུས་སྐོར།" + "Cloud Storage Usage": "སྤྲིན་གནས་སྣོད་གསོག་ལུས་སྐོར།", + "Rename Group": "ཚོགས་མིང་བསྒྱུར་བ།" } diff --git a/apps/readest-app/public/locales/de/translation.json b/apps/readest-app/public/locales/de/translation.json index e22d6570..bf3e9951 100644 --- a/apps/readest-app/public/locales/de/translation.json +++ b/apps/readest-app/public/locales/de/translation.json @@ -759,5 +759,6 @@ "Page {{current}} of {{total}}": "Seite {{current}} von {{total}}", "Are you sure to delete {{count}} selected file(s)?_one": "Möchten Sie {{count}} ausgewählte Datei wirklich löschen?", "Are you sure to delete {{count}} selected file(s)?_other": "Möchten Sie {{count}} ausgewählte Dateien wirklich löschen?", - "Cloud Storage Usage": "Cloud-Speichernutzung" + "Cloud Storage Usage": "Cloud-Speichernutzung", + "Rename Group": "Gruppe umbenennen" } diff --git a/apps/readest-app/public/locales/el/translation.json b/apps/readest-app/public/locales/el/translation.json index ec11face..b51e4eb0 100644 --- a/apps/readest-app/public/locales/el/translation.json +++ b/apps/readest-app/public/locales/el/translation.json @@ -759,5 +759,6 @@ "Page {{current}} of {{total}}": "Σελίδα {{current}} από {{total}}", "Are you sure to delete {{count}} selected file(s)?_one": "Σίγουρα θέλετε να διαγράψετε {{count}} επιλεγμένο αρχείο;", "Are you sure to delete {{count}} selected file(s)?_other": "Σίγουρα θέλετε να διαγράψετε {{count}} επιλεγμένα αρχεία;", - "Cloud Storage Usage": "Χρήση αποθήκευσης cloud" + "Cloud Storage Usage": "Χρήση αποθήκευσης cloud", + "Rename Group": "Μετονομασία ομάδας" } diff --git a/apps/readest-app/public/locales/es/translation.json b/apps/readest-app/public/locales/es/translation.json index 20c15014..f0da8c84 100644 --- a/apps/readest-app/public/locales/es/translation.json +++ b/apps/readest-app/public/locales/es/translation.json @@ -768,5 +768,6 @@ "Are you sure to delete {{count}} selected file(s)?_one": "¿Seguro que deseas eliminar {{count}} archivo seleccionado?", "Are you sure to delete {{count}} selected file(s)?_many": "¿Seguro que deseas eliminar {{count}} archivos seleccionados?", "Are you sure to delete {{count}} selected file(s)?_other": "¿Seguro que deseas eliminar {{count}} archivos seleccionados?", - "Cloud Storage Usage": "Uso de almacenamiento en la nube" + "Cloud Storage Usage": "Uso de almacenamiento en la nube", + "Rename Group": "Renombrar grupo" } diff --git a/apps/readest-app/public/locales/fa/translation.json b/apps/readest-app/public/locales/fa/translation.json index 14ff5d8b..b40bc4d7 100644 --- a/apps/readest-app/public/locales/fa/translation.json +++ b/apps/readest-app/public/locales/fa/translation.json @@ -759,5 +759,6 @@ "Page {{current}} of {{total}}": "صفحه {{current}} از {{total}}", "Are you sure to delete {{count}} selected file(s)?_one": "آیا از حذف {{count}} فایل انتخاب‌شده مطمئن هستید؟", "Are you sure to delete {{count}} selected file(s)?_other": "آیا از حذف {{count}} فایل انتخاب‌شده مطمئن هستید؟", - "Cloud Storage Usage": "استفاده از فضای ذخیره‌سازی ابری" + "Cloud Storage Usage": "استفاده از فضای ذخیره‌سازی ابری", + "Rename Group": "تغییر نام گروه" } diff --git a/apps/readest-app/public/locales/fr/translation.json b/apps/readest-app/public/locales/fr/translation.json index 8b030ede..7e99d120 100644 --- a/apps/readest-app/public/locales/fr/translation.json +++ b/apps/readest-app/public/locales/fr/translation.json @@ -768,5 +768,6 @@ "Are you sure to delete {{count}} selected file(s)?_one": "Voulez-vous vraiment supprimer {{count}} fichier sélectionné ?", "Are you sure to delete {{count}} selected file(s)?_many": "Voulez-vous vraiment supprimer {{count}} fichiers sélectionnés ?", "Are you sure to delete {{count}} selected file(s)?_other": "Voulez-vous vraiment supprimer {{count}} fichiers sélectionnés ?", - "Cloud Storage Usage": "Utilisation du stockage cloud" + "Cloud Storage Usage": "Utilisation du stockage cloud", + "Rename Group": "Renommer le groupe" } diff --git a/apps/readest-app/public/locales/hi/translation.json b/apps/readest-app/public/locales/hi/translation.json index cbf51f87..7985a65a 100644 --- a/apps/readest-app/public/locales/hi/translation.json +++ b/apps/readest-app/public/locales/hi/translation.json @@ -759,5 +759,6 @@ "Page {{current}} of {{total}}": "पृष्ठ {{current}} / {{total}}", "Are you sure to delete {{count}} selected file(s)?_one": "क्या आप वाकई {{count}} चयनित फ़ाइल हटाना चाहते हैं?", "Are you sure to delete {{count}} selected file(s)?_other": "क्या आप वाकई {{count}} चयनित फ़ाइलें हटाना चाहते हैं?", - "Cloud Storage Usage": "क्लाउड स्टोरेज उपयोग" + "Cloud Storage Usage": "क्लाउड स्टोरेज उपयोग", + "Rename Group": "समूह का नाम बदलें" } diff --git a/apps/readest-app/public/locales/id/translation.json b/apps/readest-app/public/locales/id/translation.json index 3610908c..ce09ec58 100644 --- a/apps/readest-app/public/locales/id/translation.json +++ b/apps/readest-app/public/locales/id/translation.json @@ -750,5 +750,6 @@ "files": "file", "Page {{current}} of {{total}}": "Halaman {{current}} dari {{total}}", "Are you sure to delete {{count}} selected file(s)?_other": "Yakin ingin menghapus {{count}} file yang dipilih?", - "Cloud Storage Usage": "Penggunaan Penyimpanan Cloud" + "Cloud Storage Usage": "Penggunaan Penyimpanan Cloud", + "Rename Group": "Ganti Nama Grup" } diff --git a/apps/readest-app/public/locales/it/translation.json b/apps/readest-app/public/locales/it/translation.json index 2a28fb4c..a593fdd0 100644 --- a/apps/readest-app/public/locales/it/translation.json +++ b/apps/readest-app/public/locales/it/translation.json @@ -768,5 +768,6 @@ "Are you sure to delete {{count}} selected file(s)?_one": "Sei sicuro di voler eliminare {{count}} file selezionato?", "Are you sure to delete {{count}} selected file(s)?_many": "Sei sicuro di voler eliminare {{count}} file selezionati?", "Are you sure to delete {{count}} selected file(s)?_other": "Sei sicuro di voler eliminare {{count}} file selezionati?", - "Cloud Storage Usage": "Utilizzo archiviazione cloud" + "Cloud Storage Usage": "Utilizzo archiviazione cloud", + "Rename Group": "Rinomina gruppo" } diff --git a/apps/readest-app/public/locales/ja/translation.json b/apps/readest-app/public/locales/ja/translation.json index 3093dbf0..e46e4577 100644 --- a/apps/readest-app/public/locales/ja/translation.json +++ b/apps/readest-app/public/locales/ja/translation.json @@ -750,5 +750,6 @@ "files": "ファイル", "Page {{current}} of {{total}}": "ページ {{current}} / {{total}}", "Are you sure to delete {{count}} selected file(s)?_other": "選択した {{count}} 件のファイルを削除してもよろしいですか?", - "Cloud Storage Usage": "クラウドストレージ使用量" + "Cloud Storage Usage": "クラウドストレージ使用量", + "Rename Group": "グループ名を変更" } diff --git a/apps/readest-app/public/locales/ko/translation.json b/apps/readest-app/public/locales/ko/translation.json index 0ae0481a..b10c4600 100644 --- a/apps/readest-app/public/locales/ko/translation.json +++ b/apps/readest-app/public/locales/ko/translation.json @@ -750,5 +750,6 @@ "files": "파일", "Page {{current}} of {{total}}": "페이지 {{current}} / {{total}}", "Are you sure to delete {{count}} selected file(s)?_other": "선택한 {{count}}개의 파일을 삭제하시겠습니까?", - "Cloud Storage Usage": "클라우드 저장소 사용량" + "Cloud Storage Usage": "클라우드 저장소 사용량", + "Rename Group": "그룹 이름 바꾸기" } diff --git a/apps/readest-app/public/locales/ms/translation.json b/apps/readest-app/public/locales/ms/translation.json index 252fd8ff..5d3ee15c 100644 --- a/apps/readest-app/public/locales/ms/translation.json +++ b/apps/readest-app/public/locales/ms/translation.json @@ -750,5 +750,6 @@ "files": "fail", "Page {{current}} of {{total}}": "Halaman {{current}} daripada {{total}}", "Are you sure to delete {{count}} selected file(s)?_other": "Adakah anda pasti mahu memadam {{count}} fail yang dipilih?", - "Cloud Storage Usage": "Penggunaan Storan Awan" + "Cloud Storage Usage": "Penggunaan Storan Awan", + "Rename Group": "Namakan Semula Kumpulan" } diff --git a/apps/readest-app/public/locales/nl/translation.json b/apps/readest-app/public/locales/nl/translation.json index 4fe4990a..76390609 100644 --- a/apps/readest-app/public/locales/nl/translation.json +++ b/apps/readest-app/public/locales/nl/translation.json @@ -759,5 +759,6 @@ "Page {{current}} of {{total}}": "Pagina {{current}} van {{total}}", "Are you sure to delete {{count}} selected file(s)?_one": "Weet je zeker dat je {{count}} geselecteerd bestand wilt verwijderen?", "Are you sure to delete {{count}} selected file(s)?_other": "Weet je zeker dat je {{count}} geselecteerde bestanden wilt verwijderen?", - "Cloud Storage Usage": "Cloudopslaggebruik" + "Cloud Storage Usage": "Cloudopslaggebruik", + "Rename Group": "Groep hernoemen" } diff --git a/apps/readest-app/public/locales/pl/translation.json b/apps/readest-app/public/locales/pl/translation.json index 2419f310..6c2afaa5 100644 --- a/apps/readest-app/public/locales/pl/translation.json +++ b/apps/readest-app/public/locales/pl/translation.json @@ -777,5 +777,6 @@ "Are you sure to delete {{count}} selected file(s)?_few": "Czy na pewno chcesz usunąć {{count}} wybrane pliki?", "Are you sure to delete {{count}} selected file(s)?_many": "Czy na pewno chcesz usunąć {{count}} wybranych plików?", "Are you sure to delete {{count}} selected file(s)?_other": "Czy na pewno chcesz usunąć {{count}} wybrany plik?", - "Cloud Storage Usage": "Użycie pamięci w chmurze" + "Cloud Storage Usage": "Użycie pamięci w chmurze", + "Rename Group": "Zmień nazwę grupy" } diff --git a/apps/readest-app/public/locales/pt/translation.json b/apps/readest-app/public/locales/pt/translation.json index 3981c47a..67b3dce3 100644 --- a/apps/readest-app/public/locales/pt/translation.json +++ b/apps/readest-app/public/locales/pt/translation.json @@ -768,5 +768,6 @@ "Are you sure to delete {{count}} selected file(s)?_one": "Tem certeza de que deseja apagar {{count}} ficheiro selecionado?", "Are you sure to delete {{count}} selected file(s)?_many": "Tem certeza de que deseja apagar {{count}} ficheiros selecionados?", "Are you sure to delete {{count}} selected file(s)?_other": "Tem certeza de que deseja apagar {{count}} ficheiro selecionado?", - "Cloud Storage Usage": "Uso de Armazenamento na Nuvem" + "Cloud Storage Usage": "Uso de Armazenamento na Nuvem", + "Rename Group": "Renomear Grupo" } diff --git a/apps/readest-app/public/locales/ru/translation.json b/apps/readest-app/public/locales/ru/translation.json index 0bb54b6f..943f9b2a 100644 --- a/apps/readest-app/public/locales/ru/translation.json +++ b/apps/readest-app/public/locales/ru/translation.json @@ -777,5 +777,6 @@ "Are you sure to delete {{count}} selected file(s)?_few": "Вы уверены, что хотите удалить {{count}} выбранных файла?", "Are you sure to delete {{count}} selected file(s)?_many": "Вы уверены, что хотите удалить {{count}} выбранных файлов?", "Are you sure to delete {{count}} selected file(s)?_other": "Вы уверены, что хотите удалить {{count}} выбранный файл?", - "Cloud Storage Usage": "Использование облачного хранилища" + "Cloud Storage Usage": "Использование облачного хранилища", + "Rename Group": "Переименовать группу" } diff --git a/apps/readest-app/public/locales/si/translation.json b/apps/readest-app/public/locales/si/translation.json index aa4918dd..bb252ec6 100644 --- a/apps/readest-app/public/locales/si/translation.json +++ b/apps/readest-app/public/locales/si/translation.json @@ -759,5 +759,6 @@ "Page {{current}} of {{total}}": "පිටුව {{current}} / {{total}}", "Are you sure to delete {{count}} selected file(s)?_one": "තෝරාගත් ගොනුව මකන්නට විශ්වාසද?", "Are you sure to delete {{count}} selected file(s)?_other": "තෝරාගත් ගොනු මකන්නට විශ්වාසද?", - "Cloud Storage Usage": "කලාප ගබඩා භාවිතය" + "Cloud Storage Usage": "කලාප ගබඩා භාවිතය", + "Rename Group": "කණ්ඩායම නැවත නම් කරන්න" } diff --git a/apps/readest-app/public/locales/sv/translation.json b/apps/readest-app/public/locales/sv/translation.json index 29de8cdc..5e358ca5 100644 --- a/apps/readest-app/public/locales/sv/translation.json +++ b/apps/readest-app/public/locales/sv/translation.json @@ -759,5 +759,6 @@ "Page {{current}} of {{total}}": "Sida {{current}} av {{total}}", "Are you sure to delete {{count}} selected file(s)?_one": "Är du säker på att du vill radera filen?", "Are you sure to delete {{count}} selected file(s)?_other": "Är du säker på att du vill radera filerna?", - "Cloud Storage Usage": "Användning av molnlagring" + "Cloud Storage Usage": "Användning av molnlagring", + "Rename Group": "Byt namn på grupp" } diff --git a/apps/readest-app/public/locales/ta/translation.json b/apps/readest-app/public/locales/ta/translation.json index c95ff6ca..8f770b4b 100644 --- a/apps/readest-app/public/locales/ta/translation.json +++ b/apps/readest-app/public/locales/ta/translation.json @@ -759,5 +759,6 @@ "Page {{current}} of {{total}}": "பக்கம் {{current}} / {{total}}", "Are you sure to delete {{count}} selected file(s)?_one": "இந்த கோப்பை நீக்க விரும்புகிறீர்களா?", "Are you sure to delete {{count}} selected file(s)?_other": "இந்த கோப்புகளை நீக்க விரும்புகிறீர்களா?", - "Cloud Storage Usage": "மேக சேமிப்பு பயன்பாடு" + "Cloud Storage Usage": "மேக சேமிப்பு பயன்பாடு", + "Rename Group": "குழுவை மறுபெயரிடவும்" } diff --git a/apps/readest-app/public/locales/th/translation.json b/apps/readest-app/public/locales/th/translation.json index cddd9443..4ba5b894 100644 --- a/apps/readest-app/public/locales/th/translation.json +++ b/apps/readest-app/public/locales/th/translation.json @@ -750,5 +750,6 @@ "files": "ไฟล์", "Page {{current}} of {{total}}": "หน้า {{current}} จาก {{total}}", "Are you sure to delete {{count}} selected file(s)?_other": "คุณแน่ใจหรือว่าต้องการลบไฟล์ที่เลือก?", - "Cloud Storage Usage": "การใช้งานพื้นที่เก็บข้อมูลคลาวด์" + "Cloud Storage Usage": "การใช้งานพื้นที่เก็บข้อมูลคลาวด์", + "Rename Group": "เปลี่ยนชื่อกลุ่ม" } diff --git a/apps/readest-app/public/locales/tr/translation.json b/apps/readest-app/public/locales/tr/translation.json index b39eca77..3ae885ad 100644 --- a/apps/readest-app/public/locales/tr/translation.json +++ b/apps/readest-app/public/locales/tr/translation.json @@ -759,5 +759,6 @@ "Page {{current}} of {{total}}": "{{total}} sayfa içinde {{current}}. sayfa", "Are you sure to delete {{count}} selected file(s)?_one": "Seçilen {{count}} dosyayı silmek istediğinizden emin misiniz?", "Are you sure to delete {{count}} selected file(s)?_other": "Seçilen {{count}} dosyayı silmek istediğinizden emin misiniz?", - "Cloud Storage Usage": "Bulut Depolama Kullanımı" + "Cloud Storage Usage": "Bulut Depolama Kullanımı", + "Rename Group": "Grubu Yeniden Adlandır" } diff --git a/apps/readest-app/public/locales/uk/translation.json b/apps/readest-app/public/locales/uk/translation.json index 25d70753..a26339d3 100644 --- a/apps/readest-app/public/locales/uk/translation.json +++ b/apps/readest-app/public/locales/uk/translation.json @@ -777,5 +777,6 @@ "Are you sure to delete {{count}} selected file(s)?_few": "Ви впевнені, що хочете видалити {{count}} файли?", "Are you sure to delete {{count}} selected file(s)?_many": "Ви впевнені, що хочете видалити {{count}} файлів?", "Are you sure to delete {{count}} selected file(s)?_other": "Ви впевнені, що хочете видалити {{count}} файлів?", - "Cloud Storage Usage": "Використання хмарного сховища" + "Cloud Storage Usage": "Використання хмарного сховища", + "Rename Group": "Перейменувати групу" } diff --git a/apps/readest-app/public/locales/vi/translation.json b/apps/readest-app/public/locales/vi/translation.json index c1f10c81..8c8ebad8 100644 --- a/apps/readest-app/public/locales/vi/translation.json +++ b/apps/readest-app/public/locales/vi/translation.json @@ -750,5 +750,6 @@ "files": "tệp", "Page {{current}} of {{total}}": "Trang {{current}} trên {{total}}", "Are you sure to delete {{count}} selected file(s)?_other": "Bạn có chắc muốn xóa {{count}} tệp đã chọn không?", - "Cloud Storage Usage": "Sử dụng lưu trữ đám mây" + "Cloud Storage Usage": "Sử dụng lưu trữ đám mây", + "Rename Group": "Đổi tên nhóm" } diff --git a/apps/readest-app/public/locales/zh-CN/translation.json b/apps/readest-app/public/locales/zh-CN/translation.json index 566ea459..ad6fa445 100644 --- a/apps/readest-app/public/locales/zh-CN/translation.json +++ b/apps/readest-app/public/locales/zh-CN/translation.json @@ -750,5 +750,6 @@ "files": "文件", "Page {{current}} of {{total}}": "第 {{current}} 页,共 {{total}} 页", "Are you sure to delete {{count}} selected file(s)?_other": "确定要删除已选择的 {{count}} 个文件吗?", - "Cloud Storage Usage": "云存储使用情况" + "Cloud Storage Usage": "云存储使用情况", + "Rename Group": "重命名分组" } diff --git a/apps/readest-app/public/locales/zh-TW/translation.json b/apps/readest-app/public/locales/zh-TW/translation.json index a3037910..74ec29e3 100644 --- a/apps/readest-app/public/locales/zh-TW/translation.json +++ b/apps/readest-app/public/locales/zh-TW/translation.json @@ -750,5 +750,6 @@ "files": "檔案", "Page {{current}} of {{total}}": "第 {{current}} 頁,共 {{total}} 頁", "Are you sure to delete {{count}} selected file(s)?_other": "確定要刪除已選擇的 {{count}} 個檔案嗎?", - "Cloud Storage Usage": "雲端儲存使用情況" + "Cloud Storage Usage": "雲端儲存使用情況", + "Rename Group": "重新命名" } diff --git a/apps/readest-app/src/app/library/components/GroupingModal.tsx b/apps/readest-app/src/app/library/components/GroupingModal.tsx index 85541d79..5e009951 100644 --- a/apps/readest-app/src/app/library/components/GroupingModal.tsx +++ b/apps/readest-app/src/app/library/components/GroupingModal.tsx @@ -1,6 +1,6 @@ import clsx from 'clsx'; import React, { useEffect, useRef, useState } from 'react'; -import { MdCheck, MdChevronRight } from 'react-icons/md'; +import { MdCheck, MdChevronRight, MdEdit } from 'react-icons/md'; import { HiOutlineFolder, HiOutlineFolderAdd, HiOutlineFolderRemove } from 'react-icons/hi'; import { IoMdArrowBack } from 'react-icons/io'; @@ -31,14 +31,23 @@ const GroupingModal: React.FC = ({ }) => { const _ = useTranslation(); const { appService } = useEnv(); - const { setLibrary, addGroup, getGroups, getGroupsByParent, getParentPath, refreshGroups } = - useLibraryStore(); + const { + setLibrary, + addGroup, + getGroups, + getGroupId, + getGroupsByParent, + getParentPath, + refreshGroups, + } = useLibraryStore(); const [currentPath, setCurrentPath] = useState(undefined); const [showInput, setShowInput] = useState(false); const [editGroupName, setEditGroupName] = useState(''); const [selectedGroup, setSelectedGroup] = useState(null); const [newGroup, setNewGroup] = useState(null); + const [isRenaming, setIsRenaming] = useState(false); + const [originalGroupName, setOriginalGroupName] = useState(null); const divRef = useKeyDownActions({ onCancel, onConfirm }); const editorRef = useRef(null); @@ -59,6 +68,11 @@ const GroupingModal: React.FC = ({ .map((hash) => libraryBooks.find((book) => book.hash === hash)?.groupId) .some((group) => group && group !== BOOK_UNGROUPED_NAME); + const canRenameGroup = selectedBooks.length === 1 && selectedBooks.every((id) => !isMd5(id)); + const currentGroupForRename = canRenameGroup + ? allGroups.find((group) => group.id === selectedBooks[0]) + : null; + const generateNextUntitledGroupName = () => { const baseName = _('Untitled Group'); const basePattern = parentGroupName @@ -86,6 +100,17 @@ const GroupingModal: React.FC = ({ const nextName = generateNextUntitledGroupName(); setEditGroupName(nextName); setShowInput(true); + setIsRenaming(false); + setOriginalGroupName(null); + }; + + const handleRenameGroup = () => { + if (!currentGroupForRename) return; + + setEditGroupName(currentGroupForRename.name); + setOriginalGroupName(currentGroupForRename.name); + setShowInput(true); + setIsRenaming(true); }; const handleRemoveFromGroup = () => { @@ -112,17 +137,44 @@ const GroupingModal: React.FC = ({ const handleConfirmCreateGroup = () => { let groupName = editGroupName.trim(); if (groupName) { - if (currentPath && !groupName.startsWith(currentPath + '/')) { - groupName = `${currentPath}/${groupName}`; - } + if (isRenaming && originalGroupName) { + // Renaming existing group + const oldGroupName = originalGroupName; - const newGroup = addGroup(groupName); - setNewGroup(newGroup); - setSelectedGroup(newGroup); - setShowInput(false); - const parentGroup = getParentPath(groupName); - if (parentGroup) { - setCurrentPath(parentGroup); + // Update the group name for all books in this group and nested groups + libraryBooks.forEach((book) => { + if (book.groupName === oldGroupName) { + book.groupName = groupName; + book.groupId = getGroupId(book.groupName); + book.updatedAt = Date.now(); + } else if (book.groupName?.startsWith(oldGroupName + '/')) { + book.groupName = book.groupName.replace(oldGroupName, groupName); + book.groupId = getGroupId(book.groupName); + book.updatedAt = Date.now(); + } + }); + + setLibrary([...libraryBooks]); + appService?.saveLibraryBooks(libraryBooks); + + refreshGroups(); + setShowInput(false); + setIsRenaming(false); + setOriginalGroupName(null); + } else { + // Creating new group + if (currentPath && !groupName.startsWith(currentPath + '/')) { + groupName = `${currentPath}/${groupName}`; + } + + const newGroup = addGroup(groupName); + setNewGroup(newGroup); + setSelectedGroup(newGroup); + setShowInput(false); + const parentGroup = getParentPath(groupName); + if (parentGroup) { + setCurrentPath(parentGroup); + } } } }; @@ -205,25 +257,32 @@ const GroupingModal: React.FC = ({ {/* Action buttons */}
- {isSelectedBooksHasGroup && ( - - )} + +
- {/* Create group input */} + {/* Create/Rename group input */} {showInput && (
@@ -234,7 +293,11 @@ const GroupingModal: React.FC = ({ onChange={(e) => setEditGroupName(e.target.value)} onKeyDown={(e) => { if (e.key === 'Enter') handleConfirmCreateGroup(); - if (e.key === 'Escape') setShowInput(false); + if (e.key === 'Escape') { + setShowInput(false); + setIsRenaming(false); + setOriginalGroupName(null); + } e.stopPropagation(); }} className='input input-ghost w-full border-0 px-2 text-base !outline-none sm:text-sm' diff --git a/apps/readest-app/src/store/libraryStore.ts b/apps/readest-app/src/store/libraryStore.ts index c302f639..5d19cce7 100644 --- a/apps/readest-app/src/store/libraryStore.ts +++ b/apps/readest-app/src/store/libraryStore.ts @@ -1,7 +1,7 @@ import { create } from 'zustand'; import { Book, BookGroupType, BooksGroup } from '@/types/book'; import { EnvConfigType, isTauriAppPlatform } from '@/services/environment'; -import { BOOK_UNGROUPED_ID, BOOK_UNGROUPED_NAME } from '@/services/constants'; +import { BOOK_UNGROUPED_NAME } from '@/services/constants'; import { md5Fingerprint } from '@/utils/md5'; interface LibraryState { @@ -94,19 +94,12 @@ export const useLibraryStore = create((set, get) => ({ const groups: Record = {}; library.forEach((book) => { - if ( - book.groupId && - book.groupName && - book.groupId !== BOOK_UNGROUPED_ID && - book.groupName !== BOOK_UNGROUPED_NAME && - !book.deletedAt - ) { - groups[book.groupId] = book.groupName; + if (book.groupName && book.groupName !== BOOK_UNGROUPED_NAME && !book.deletedAt) { + groups[md5Fingerprint(book.groupName)] = book.groupName; let nextSlashIndex = book.groupName.indexOf('/', 0); while (nextSlashIndex > 0) { const groupName = book.groupName.substring(0, nextSlashIndex); - const groupId = md5Fingerprint(groupName); - groups[groupId] = groupName; + groups[md5Fingerprint(groupName)] = groupName; nextSlashIndex = book.groupName.indexOf('/', nextSlashIndex + 1); } }