diff --git a/apps/readest-app/public/locales/ar/translation.json b/apps/readest-app/public/locales/ar/translation.json index 9659d486..651fe380 100644 --- a/apps/readest-app/public/locales/ar/translation.json +++ b/apps/readest-app/public/locales/ar/translation.json @@ -1944,5 +1944,6 @@ "Show recently read": "إظهار المقروءة مؤخرًا", "Find:": "بحث:", "Enable rule": "تفعيل القاعدة", - "Disable rule": "تعطيل القاعدة" + "Disable rule": "تعطيل القاعدة", + "Progress Read": "تقدم القراءة" } diff --git a/apps/readest-app/public/locales/bn/translation.json b/apps/readest-app/public/locales/bn/translation.json index d7ab7e7f..dccb515a 100644 --- a/apps/readest-app/public/locales/bn/translation.json +++ b/apps/readest-app/public/locales/bn/translation.json @@ -1812,5 +1812,6 @@ "Show recently read": "সম্প্রতি পড়া দেখান", "Find:": "খুঁজুন:", "Enable rule": "নিয়ম সক্রিয় করুন", - "Disable rule": "নিয়ম নিষ্ক্রিয় করুন" + "Disable rule": "নিয়ম নিষ্ক্রিয় করুন", + "Progress Read": "পড়ার অগ্রগতি" } diff --git a/apps/readest-app/public/locales/bo/translation.json b/apps/readest-app/public/locales/bo/translation.json index 2331f048..a4d22ffe 100644 --- a/apps/readest-app/public/locales/bo/translation.json +++ b/apps/readest-app/public/locales/bo/translation.json @@ -1773,5 +1773,6 @@ "Show recently read": "ཉེ་ཆར་བཀླགས་པ་སྟོན་པ།", "Find:": "འཚོལ་བཤེར།:", "Enable rule": "སྲིད་སྒྲིག་སྤྱོད་པ།", - "Disable rule": "སྲིད་སྒྲིག་སྒོ་བརྒྱབ།" + "Disable rule": "སྲིད་སྒྲིག་སྒོ་བརྒྱབ།", + "Progress Read": "ཀློག་པའི་ཡར་འཕེལ།" } diff --git a/apps/readest-app/public/locales/de/translation.json b/apps/readest-app/public/locales/de/translation.json index 25bed85a..2781be34 100644 --- a/apps/readest-app/public/locales/de/translation.json +++ b/apps/readest-app/public/locales/de/translation.json @@ -1812,5 +1812,6 @@ "Show recently read": "Zuletzt gelesen anzeigen", "Find:": "Suchen:", "Enable rule": "Regel aktivieren", - "Disable rule": "Regel deaktivieren" + "Disable rule": "Regel deaktivieren", + "Progress Read": "Lesefortschritt" } diff --git a/apps/readest-app/public/locales/el/translation.json b/apps/readest-app/public/locales/el/translation.json index 66ebb071..16bbc68d 100644 --- a/apps/readest-app/public/locales/el/translation.json +++ b/apps/readest-app/public/locales/el/translation.json @@ -1812,5 +1812,6 @@ "Show recently read": "Εμφάνιση πρόσφατα αναγνωσμένων", "Find:": "Εύρεση:", "Enable rule": "Ενεργοποίηση κανόνα", - "Disable rule": "Απενεργοποίηση κανόνα" + "Disable rule": "Απενεργοποίηση κανόνα", + "Progress Read": "Πρόοδος ανάγνωσης" } diff --git a/apps/readest-app/public/locales/es/translation.json b/apps/readest-app/public/locales/es/translation.json index e0edfc95..ebaf4fbb 100644 --- a/apps/readest-app/public/locales/es/translation.json +++ b/apps/readest-app/public/locales/es/translation.json @@ -1845,5 +1845,6 @@ "Show recently read": "Mostrar leídos recientemente", "Find:": "Buscar:", "Enable rule": "Activar regla", - "Disable rule": "Desactivar regla" + "Disable rule": "Desactivar regla", + "Progress Read": "Progreso de Lectura" } diff --git a/apps/readest-app/public/locales/fa/translation.json b/apps/readest-app/public/locales/fa/translation.json index 0db165c7..4fea22b0 100644 --- a/apps/readest-app/public/locales/fa/translation.json +++ b/apps/readest-app/public/locales/fa/translation.json @@ -1812,5 +1812,6 @@ "Show recently read": "نمایش موارد اخیراً خوانده‌شده", "Find:": "جستجو:", "Enable rule": "فعال کردن قانون", - "Disable rule": "غیرفعال کردن قانون" + "Disable rule": "غیرفعال کردن قانون", + "Progress Read": "وضعیت مطالعه" } diff --git a/apps/readest-app/public/locales/fr/translation.json b/apps/readest-app/public/locales/fr/translation.json index 71c7ced9..99f6200e 100644 --- a/apps/readest-app/public/locales/fr/translation.json +++ b/apps/readest-app/public/locales/fr/translation.json @@ -1845,5 +1845,6 @@ "Show recently read": "Afficher les lectures récentes", "Find:": "Rechercher :", "Enable rule": "Activer la règle", - "Disable rule": "Désactiver la règle" + "Disable rule": "Désactiver la règle", + "Progress Read": "Progression de lecture" } diff --git a/apps/readest-app/public/locales/he/translation.json b/apps/readest-app/public/locales/he/translation.json index de87495c..9ac63a17 100644 --- a/apps/readest-app/public/locales/he/translation.json +++ b/apps/readest-app/public/locales/he/translation.json @@ -1845,5 +1845,6 @@ "Show recently read": "הצגת ספרים שנקראו לאחרונה", "Find:": "חיפוש:", "Enable rule": "הפעל כלל", - "Disable rule": "השבת כלל" + "Disable rule": "השבת כלל", + "Progress Read": "התקדמות קריאה" } diff --git a/apps/readest-app/public/locales/hi/translation.json b/apps/readest-app/public/locales/hi/translation.json index 7c1c83db..35422acb 100644 --- a/apps/readest-app/public/locales/hi/translation.json +++ b/apps/readest-app/public/locales/hi/translation.json @@ -1812,5 +1812,6 @@ "Show recently read": "हाल ही में पढ़े गए दिखाएँ", "Find:": "खोजें:", "Enable rule": "नियम सक्षम करें", - "Disable rule": "नियम अक्षम करें" + "Disable rule": "नियम अक्षम करें", + "Progress Read": "पढ़ने की प्रगति" } diff --git a/apps/readest-app/public/locales/hu/translation.json b/apps/readest-app/public/locales/hu/translation.json index 49886da9..a4f68edb 100644 --- a/apps/readest-app/public/locales/hu/translation.json +++ b/apps/readest-app/public/locales/hu/translation.json @@ -1812,5 +1812,6 @@ "Show recently read": "Nemrég olvasottak megjelenítése", "Find:": "Keresés:", "Enable rule": "Szabály engedélyezése", - "Disable rule": "Szabály letiltása" + "Disable rule": "Szabály letiltása", + "Progress Read": "Olvasási haladás" } diff --git a/apps/readest-app/public/locales/id/translation.json b/apps/readest-app/public/locales/id/translation.json index 49f8fb4e..dcf41cb6 100644 --- a/apps/readest-app/public/locales/id/translation.json +++ b/apps/readest-app/public/locales/id/translation.json @@ -1779,5 +1779,6 @@ "Show recently read": "Tampilkan baru dibaca", "Find:": "Cari:", "Enable rule": "Aktifkan aturan", - "Disable rule": "Nonaktifkan aturan" + "Disable rule": "Nonaktifkan aturan", + "Progress Read": "Progres Membaca" } diff --git a/apps/readest-app/public/locales/it/translation.json b/apps/readest-app/public/locales/it/translation.json index 26b87233..50b1bcc7 100644 --- a/apps/readest-app/public/locales/it/translation.json +++ b/apps/readest-app/public/locales/it/translation.json @@ -1845,5 +1845,6 @@ "Show recently read": "Mostra letti di recente", "Find:": "Trova:", "Enable rule": "Attiva regola", - "Disable rule": "Disattiva regola" + "Disable rule": "Disattiva regola", + "Progress Read": "Progresso di lettura" } diff --git a/apps/readest-app/public/locales/ja/translation.json b/apps/readest-app/public/locales/ja/translation.json index 8ec7d575..1a00cc16 100644 --- a/apps/readest-app/public/locales/ja/translation.json +++ b/apps/readest-app/public/locales/ja/translation.json @@ -1779,5 +1779,6 @@ "Show recently read": "最近読んだ本を表示", "Find:": "検索:", "Enable rule": "ルールを有効化", - "Disable rule": "ルールを無効化" + "Disable rule": "ルールを無効化", + "Progress Read": "読書進捗" } diff --git a/apps/readest-app/public/locales/ko/translation.json b/apps/readest-app/public/locales/ko/translation.json index d72e96b7..d0cc54ad 100644 --- a/apps/readest-app/public/locales/ko/translation.json +++ b/apps/readest-app/public/locales/ko/translation.json @@ -1779,5 +1779,6 @@ "Show recently read": "최근 읽은 책 표시", "Find:": "찾기:", "Enable rule": "규칙 활성화", - "Disable rule": "규칙 비활성화" + "Disable rule": "규칙 비활성화", + "Progress Read": "읽기 진행 상황" } diff --git a/apps/readest-app/public/locales/ms/translation.json b/apps/readest-app/public/locales/ms/translation.json index 81a64b10..43150876 100644 --- a/apps/readest-app/public/locales/ms/translation.json +++ b/apps/readest-app/public/locales/ms/translation.json @@ -1779,5 +1779,6 @@ "Show recently read": "Tunjukkan baru dibaca", "Find:": "Cari:", "Enable rule": "Dayakan peraturan", - "Disable rule": "Nyahdayakan peraturan" + "Disable rule": "Nyahdayakan peraturan", + "Progress Read": "Kemajuan Membaca" } diff --git a/apps/readest-app/public/locales/nl/translation.json b/apps/readest-app/public/locales/nl/translation.json index 89d98ee2..60f5566b 100644 --- a/apps/readest-app/public/locales/nl/translation.json +++ b/apps/readest-app/public/locales/nl/translation.json @@ -1812,5 +1812,6 @@ "Show recently read": "Onlangs gelezen tonen", "Find:": "Zoeken:", "Enable rule": "Regel inschakelen", - "Disable rule": "Regel uitschakelen" + "Disable rule": "Regel uitschakelen", + "Progress Read": "Leesvoortgang" } diff --git a/apps/readest-app/public/locales/pl/translation.json b/apps/readest-app/public/locales/pl/translation.json index 9938a89c..607e9ba0 100644 --- a/apps/readest-app/public/locales/pl/translation.json +++ b/apps/readest-app/public/locales/pl/translation.json @@ -1878,5 +1878,6 @@ "Show recently read": "Pokaż ostatnio czytane", "Find:": "Znajdź:", "Enable rule": "Włącz regułę", - "Disable rule": "Wyłącz regułę" + "Disable rule": "Wyłącz regułę", + "Progress Read": "Postęp czytania" } diff --git a/apps/readest-app/public/locales/pt-BR/translation.json b/apps/readest-app/public/locales/pt-BR/translation.json index 4710c06a..ab0ffd9f 100644 --- a/apps/readest-app/public/locales/pt-BR/translation.json +++ b/apps/readest-app/public/locales/pt-BR/translation.json @@ -1845,5 +1845,6 @@ "Show recently read": "Mostrar lidos recentemente", "Find:": "Localizar:", "Enable rule": "Ativar regra", - "Disable rule": "Desativar regra" + "Disable rule": "Desativar regra", + "Progress Read": "Progresso de leitura" } diff --git a/apps/readest-app/public/locales/pt/translation.json b/apps/readest-app/public/locales/pt/translation.json index 74e03a54..416be33b 100644 --- a/apps/readest-app/public/locales/pt/translation.json +++ b/apps/readest-app/public/locales/pt/translation.json @@ -1845,5 +1845,6 @@ "Show recently read": "Mostrar lidos recentemente", "Find:": "Localizar:", "Enable rule": "Ativar regra", - "Disable rule": "Desativar regra" + "Disable rule": "Desativar regra", + "Progress Read": "Progresso de Leitura" } diff --git a/apps/readest-app/public/locales/ro/translation.json b/apps/readest-app/public/locales/ro/translation.json index 5f62d401..a543abb8 100644 --- a/apps/readest-app/public/locales/ro/translation.json +++ b/apps/readest-app/public/locales/ro/translation.json @@ -1845,5 +1845,6 @@ "Show recently read": "Afișează citite recent", "Find:": "Găsește:", "Enable rule": "Activează regula", - "Disable rule": "Dezactivează regula" + "Disable rule": "Dezactivează regula", + "Progress Read": "Progresul citirii" } diff --git a/apps/readest-app/public/locales/ru/translation.json b/apps/readest-app/public/locales/ru/translation.json index 26195a02..0087b9fe 100644 --- a/apps/readest-app/public/locales/ru/translation.json +++ b/apps/readest-app/public/locales/ru/translation.json @@ -1878,5 +1878,6 @@ "Show recently read": "Показывать недавно прочитанные", "Find:": "Найти:", "Enable rule": "Включить правило", - "Disable rule": "Отключить правило" + "Disable rule": "Отключить правило", + "Progress Read": "Прогресс чтения" } diff --git a/apps/readest-app/public/locales/si/translation.json b/apps/readest-app/public/locales/si/translation.json index 5399b885..245dc4c2 100644 --- a/apps/readest-app/public/locales/si/translation.json +++ b/apps/readest-app/public/locales/si/translation.json @@ -1812,5 +1812,6 @@ "Show recently read": "මෑතකදී කියවූ ඒවා පෙන්වන්න", "Find:": "සොයන්න:", "Enable rule": "නියමය සක්‍රීය කරන්න", - "Disable rule": "නියමය අක්‍රීය කරන්න" + "Disable rule": "නියමය අක්‍රීය කරන්න", + "Progress Read": "කියවීමේ ප්‍රගතිය" } diff --git a/apps/readest-app/public/locales/sl/translation.json b/apps/readest-app/public/locales/sl/translation.json index 52ae83a1..431e5367 100644 --- a/apps/readest-app/public/locales/sl/translation.json +++ b/apps/readest-app/public/locales/sl/translation.json @@ -1878,5 +1878,6 @@ "Show recently read": "Pokaži nedavno prebrano", "Find:": "Najdi:", "Enable rule": "Omogoči pravilo", - "Disable rule": "Onemogoči pravilo" + "Disable rule": "Onemogoči pravilo", + "Progress Read": "Napredek branja" } diff --git a/apps/readest-app/public/locales/sv/translation.json b/apps/readest-app/public/locales/sv/translation.json index e4e1a3ae..06b26d21 100644 --- a/apps/readest-app/public/locales/sv/translation.json +++ b/apps/readest-app/public/locales/sv/translation.json @@ -1812,5 +1812,6 @@ "Show recently read": "Visa nyligen lästa", "Find:": "Sök:", "Enable rule": "Aktivera regel", - "Disable rule": "Inaktivera regel" + "Disable rule": "Inaktivera regel", + "Progress Read": "Läsframsteg" } diff --git a/apps/readest-app/public/locales/ta/translation.json b/apps/readest-app/public/locales/ta/translation.json index 42cbe010..53937138 100644 --- a/apps/readest-app/public/locales/ta/translation.json +++ b/apps/readest-app/public/locales/ta/translation.json @@ -1812,5 +1812,6 @@ "Show recently read": "சமீபத்தில் படித்தவற்றைக் காட்டு", "Find:": "தேடு:", "Enable rule": "விதியை இயக்கு", - "Disable rule": "விதியை முடக்கு" + "Disable rule": "விதியை முடக்கு", + "Progress Read": "வாசிப்பு முன்னேற்றம்" } diff --git a/apps/readest-app/public/locales/th/translation.json b/apps/readest-app/public/locales/th/translation.json index caa85901..fcbfc1e4 100644 --- a/apps/readest-app/public/locales/th/translation.json +++ b/apps/readest-app/public/locales/th/translation.json @@ -1779,5 +1779,6 @@ "Show recently read": "แสดงรายการอ่านล่าสุด", "Find:": "ค้นหา:", "Enable rule": "เปิดใช้กฎ", - "Disable rule": "ปิดใช้กฎ" + "Disable rule": "ปิดใช้กฎ", + "Progress Read": "ความคืบหน้าในการอ่าน" } diff --git a/apps/readest-app/public/locales/tr/translation.json b/apps/readest-app/public/locales/tr/translation.json index 2d53a182..5cdf7e73 100644 --- a/apps/readest-app/public/locales/tr/translation.json +++ b/apps/readest-app/public/locales/tr/translation.json @@ -1812,5 +1812,6 @@ "Show recently read": "Son okunanları göster", "Find:": "Bul:", "Enable rule": "Kuralı etkinleştir", - "Disable rule": "Kuralı devre dışı bırak" + "Disable rule": "Kuralı devre dışı bırak", + "Progress Read": "Okuma İlerlemesi" } diff --git a/apps/readest-app/public/locales/uk/translation.json b/apps/readest-app/public/locales/uk/translation.json index b2ff6897..332e4523 100644 --- a/apps/readest-app/public/locales/uk/translation.json +++ b/apps/readest-app/public/locales/uk/translation.json @@ -1878,5 +1878,6 @@ "Show recently read": "Показувати нещодавно прочитані", "Find:": "Знайти:", "Enable rule": "Увімкнути правило", - "Disable rule": "Вимкнути правило" + "Disable rule": "Вимкнути правило", + "Progress Read": "Проґрес читання" } diff --git a/apps/readest-app/public/locales/uz/translation.json b/apps/readest-app/public/locales/uz/translation.json index 4d7775be..b0a39fe5 100644 --- a/apps/readest-app/public/locales/uz/translation.json +++ b/apps/readest-app/public/locales/uz/translation.json @@ -1812,5 +1812,6 @@ "Show recently read": "Yaqinda o'qilganlarni ko'rsatish", "Find:": "Topish:", "Enable rule": "Qoidani yoqish", - "Disable rule": "Qoidani o‘chirish" + "Disable rule": "Qoidani o‘chirish", + "Progress Read": "Oʻqish jarayoni" } diff --git a/apps/readest-app/public/locales/vi/translation.json b/apps/readest-app/public/locales/vi/translation.json index 5c96215e..9e18a780 100644 --- a/apps/readest-app/public/locales/vi/translation.json +++ b/apps/readest-app/public/locales/vi/translation.json @@ -1779,5 +1779,6 @@ "Show recently read": "Hiển thị mục đã đọc gần đây", "Find:": "Tìm:", "Enable rule": "Bật quy tắc", - "Disable rule": "Tắt quy tắc" + "Disable rule": "Tắt quy tắc", + "Progress Read": "Tiến độ đọc" } diff --git a/apps/readest-app/public/locales/zh-CN/translation.json b/apps/readest-app/public/locales/zh-CN/translation.json index 381895c2..46d76be9 100644 --- a/apps/readest-app/public/locales/zh-CN/translation.json +++ b/apps/readest-app/public/locales/zh-CN/translation.json @@ -1779,5 +1779,6 @@ "Show recently read": "显示最近阅读", "Find:": "查找:", "Enable rule": "启用规则", - "Disable rule": "禁用规则" + "Disable rule": "禁用规则", + "Progress Read": "阅读进度" } diff --git a/apps/readest-app/public/locales/zh-TW/translation.json b/apps/readest-app/public/locales/zh-TW/translation.json index 8f4c44d0..c660321f 100644 --- a/apps/readest-app/public/locales/zh-TW/translation.json +++ b/apps/readest-app/public/locales/zh-TW/translation.json @@ -1779,5 +1779,6 @@ "Show recently read": "顯示最近閱讀", "Find:": "尋找:", "Enable rule": "啟用規則", - "Disable rule": "停用規則" + "Disable rule": "停用規則", + "Progress Read": "閱讀進度" } diff --git a/apps/readest-app/src/__tests__/app/library/library-utils-extended.test.ts b/apps/readest-app/src/__tests__/app/library/library-utils-extended.test.ts index 06f8f4dd..9ef4ae23 100644 --- a/apps/readest-app/src/__tests__/app/library/library-utils-extended.test.ts +++ b/apps/readest-app/src/__tests__/app/library/library-utils-extended.test.ts @@ -195,6 +195,21 @@ describe('getBookSortValue', () => { const book = createMockBook({ updatedAt: 99999 }); expect(getBookSortValue(book, 'unknown' as LibrarySortByType)).toBe(99999); }); + + it('should return read ratio for Progress sort', () => { + const book = createMockBook({ progress: [50, 100] }); + expect(getBookSortValue(book, LibrarySortByType.Progress)).toBe(0.5); + }); + + it('should return 0 for Progress sort when book has no progress', () => { + const book = createMockBook({}); + expect(getBookSortValue(book, LibrarySortByType.Progress)).toBe(0); + }); + + it('should return 0 for Progress sort when total pages is 0', () => { + const book = createMockBook({ progress: [0, 0] }); + expect(getBookSortValue(book, LibrarySortByType.Progress)).toBe(0); + }); }); describe('compareSortValues', () => { @@ -310,4 +325,21 @@ describe('createBookSorter - additional cases', () => { expect(sorted[0]!.title).toBe('Older'); expect(sorted[1]!.title).toBe('Newer'); }); + + it('should sort by reading progress ascending (unread books first)', () => { + const books = [ + createMockBook({ title: 'Almost done', progress: [90, 100] }), + createMockBook({ title: 'Not started' }), + createMockBook({ title: 'Just begun', progress: [10, 100] }), + createMockBook({ title: 'Halfway', progress: [1, 2] }), + ]; + const sorter = createBookSorter(LibrarySortByType.Progress, 'en'); + const sorted = [...books].sort(sorter); + expect(sorted.map((b) => b.title)).toEqual([ + 'Not started', + 'Just begun', + 'Halfway', + 'Almost done', + ]); + }); }); diff --git a/apps/readest-app/src/__tests__/utils/library-utils.test.ts b/apps/readest-app/src/__tests__/utils/library-utils.test.ts index 587feba9..e16b3e26 100644 --- a/apps/readest-app/src/__tests__/utils/library-utils.test.ts +++ b/apps/readest-app/src/__tests__/utils/library-utils.test.ts @@ -544,6 +544,18 @@ describe('getGroupSortValue', () => { expect(getGroupSortValue(group, LibrarySortByType.Series)).toBe('My Series'); }); + it('should return max read ratio for progress sort', () => { + const group = createMockGroup({ + books: [ + createMockBook({ progress: [10, 100] }), + createMockBook({ progress: [80, 100] }), + createMockBook({}), + ], + }); + + expect(getGroupSortValue(group, LibrarySortByType.Progress)).toBe(0.8); + }); + it('should handle empty groups gracefully', () => { const group = createMockGroup({ books: [] }); diff --git a/apps/readest-app/src/app/library/components/ViewMenu.tsx b/apps/readest-app/src/app/library/components/ViewMenu.tsx index 6edae830..885d0a1b 100644 --- a/apps/readest-app/src/app/library/components/ViewMenu.tsx +++ b/apps/readest-app/src/app/library/components/ViewMenu.tsx @@ -76,6 +76,7 @@ const ViewMenu: React.FC = ({ setIsDropdownOpen }) => { { label: _('Date Read'), value: LibrarySortByType.Updated }, { label: _('Date Added'), value: LibrarySortByType.Created }, { label: _('Date Published'), value: LibrarySortByType.Published }, + { label: _('Progress Read'), value: LibrarySortByType.Progress }, ]; const sortBy2Options: { label: string; value: LibrarySecondarySortByType }[] = [ diff --git a/apps/readest-app/src/app/library/utils/libraryUtils.ts b/apps/readest-app/src/app/library/utils/libraryUtils.ts index 1a3aa284..b3d47a8d 100644 --- a/apps/readest-app/src/app/library/utils/libraryUtils.ts +++ b/apps/readest-app/src/app/library/utils/libraryUtils.ts @@ -178,6 +178,17 @@ export const createBookFilter = (queryTerm: string | null) => (item: Book) => { ); }; +/** + * Fraction of the book that has been read, in [0, 1]. `progress` is a 1-based + * `[current, total]` page pair; books that have never been opened have no + * progress and read 0 (they sort to the unread end). + */ +const getBookReadRatio = (book: Book): number => { + const [current, total] = book.progress ?? []; + if (!current || !total || total <= 0) return 0; + return current / total; +}; + const compareBookByKey = (a: Book, b: Book, sortBy: string, uiLanguage: string): number => { switch (sortBy) { case LibrarySortByType.Title: { @@ -196,6 +207,8 @@ const compareBookByKey = (a: Book, b: Book, sortBy: string, uiLanguage: string): return new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime(); case LibrarySortByType.Format: return a.format.localeCompare(b.format, uiLanguage || navigator.language); + case LibrarySortByType.Progress: + return getBookReadRatio(a) - getBookReadRatio(b); case LibrarySortByType.Series: { // Group by series name first so books of the same series stay consecutive, // then order within a series by index. Comparing index alone would interleave @@ -496,6 +509,9 @@ export const getBookSortValue = (book: Book, sortBy: LibrarySortByType): number case LibrarySortByType.Format: return book.format; + case LibrarySortByType.Progress: + return getBookReadRatio(book); + case LibrarySortByType.Published: { const published = book.metadata?.published; if (!published) return 0; @@ -555,6 +571,10 @@ export const getGroupSortValue = ( // Return the most recent createdAt return Math.max(...books.map((b) => b.createdAt)); + case LibrarySortByType.Progress: + // Return the most-progressed book's read ratio + return Math.max(...books.map((b) => getBookReadRatio(b))); + case LibrarySortByType.Published: { // Return the most recent published date const publishedDates = books diff --git a/apps/readest-app/src/types/settings.ts b/apps/readest-app/src/types/settings.ts index dfa938ef..eb38ec9d 100644 --- a/apps/readest-app/src/types/settings.ts +++ b/apps/readest-app/src/types/settings.ts @@ -18,6 +18,7 @@ export const LibrarySortByType = { Size: 'size', Format: 'format', Published: 'published', + Progress: 'progress', } as const; export type LibrarySortByType = (typeof LibrarySortByType)[keyof typeof LibrarySortByType];