worldhopper/lib/database/tables/reading_progress_table.dart
Felipe M. 1074e3808d
feat: basic navigation
feat: navigation store

feat: implement OPDS entry caching system

Add comprehensive caching for OPDS publications with local image storage and Dublin Core Terms metadata extraction. This enables offline viewing, fixes Library screen to show book titles and covers, and improves overall UX.

- Add publications table with full metadata (title, authors, series, publisher, ISBN, language)
- Implement local image cache service for covers and thumbnails
- Extract DCTerms metadata (series, publisher, language, ISBN) from OPDS feeds
- Link reading progress to cached publications
- Update Library screen to display cached publication data and covers
- Cache publications automatically when starting to read
- Fix navigation stack issues by using context.push() instead of context.go()
- Add explicit back button to EPUB reader with proper PopScope handling
- Implement UNIQUE constraint on reading_progress to prevent duplicates
- Save reading progress on screen dispose for both EPUB and image readers

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-28 18:24:07 +01:00

44 lines
1.5 KiB
Dart

/// SQL schema for the reading_progress table
class ReadingProgressTable {
ReadingProgressTable._();
static const String tableName = 'reading_progress';
/// SQL statement to create the reading_progress table
static const String createTable = '''
CREATE TABLE $tableName (
id TEXT PRIMARY KEY,
publication_id TEXT NOT NULL,
server_id TEXT NOT NULL,
current_page INTEGER NOT NULL DEFAULT 0,
total_pages INTEGER NOT NULL,
epub_location TEXT,
last_read_at INTEGER NOT NULL,
publication_cache_id TEXT,
FOREIGN KEY (server_id) REFERENCES servers(id) ON DELETE CASCADE,
FOREIGN KEY (publication_cache_id) REFERENCES publications(id) ON DELETE SET NULL,
UNIQUE(publication_id, server_id)
)
''';
/// SQL statement to drop the reading_progress table
static const String dropTable = 'DROP TABLE IF EXISTS $tableName';
/// Create index on publication_id for faster lookups
static const String createPublicationIndex = '''
CREATE INDEX idx_reading_progress_publication_id
ON $tableName(publication_id)
''';
/// Create index on server_id for faster lookups
static const String createServerIndex = '''
CREATE INDEX idx_reading_progress_server_id
ON $tableName(server_id)
''';
/// Create index on publication_cache_id for faster lookups
static const String createCacheIdIndex = '''
CREATE INDEX idx_reading_progress_cache_id
ON $tableName(publication_cache_id)
''';
}