Save reader settings per book in localStorage
Each book gets its own key (diora_reader_settings_{bookId}).
Opening a book resets to defaults then applies book-specific overrides,
so zoom, spread, invert, theme etc. are remembered independently per book.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
916e8a568b
commit
6b419c6fe0
1 changed files with 9 additions and 5 deletions
|
|
@ -3099,7 +3099,7 @@ async function openBook(bookId) {
|
|||
overlay.style.display = '';
|
||||
|
||||
try {
|
||||
loadReaderSettings();
|
||||
loadReaderSettings(bookId);
|
||||
const key = await getOrCreateEncKey();
|
||||
let data_ct, data_iv;
|
||||
const cached = await _getCachedBook(bookId);
|
||||
|
|
@ -3533,11 +3533,13 @@ function jumpToTocEntry(href) {
|
|||
// Reader Settings
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function loadReaderSettings() {
|
||||
function loadReaderSettings(bookId) {
|
||||
// Reset to defaults, then apply per-book overrides
|
||||
Object.assign(readerSettings, { fontSize: 16, lineHeight: 1.8, maxWidth: 65, theme: 'dark',
|
||||
pdfZoom: 100, pdfInverted: false, pdfPaginated: false, pdfSpread: false });
|
||||
try {
|
||||
const saved = JSON.parse(localStorage.getItem('diora_reader_settings') || '{}');
|
||||
const saved = JSON.parse(localStorage.getItem(`diora_reader_settings_${bookId}`) || '{}');
|
||||
Object.assign(readerSettings, saved);
|
||||
// Auto-paginate on mobile if not explicitly set
|
||||
if (saved.pdfPaginated === undefined) {
|
||||
readerSettings.pdfPaginated = window.innerWidth < 768;
|
||||
}
|
||||
|
|
@ -3545,7 +3547,9 @@ function loadReaderSettings() {
|
|||
}
|
||||
|
||||
function saveReaderSettings() {
|
||||
localStorage.setItem('diora_reader_settings', JSON.stringify(readerSettings));
|
||||
if (currentBookId) {
|
||||
localStorage.setItem(`diora_reader_settings_${currentBookId}`, JSON.stringify(readerSettings));
|
||||
}
|
||||
}
|
||||
|
||||
function applyReaderSettings(isPdf) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue