feat: improve reading progress with validation and auto-mark

- Add autoMarkAsReadOnCompletion setting (opt-in, default: false)
- Implement auto-mark as read when reaching 95%+ completion
- Add validation for progress bounds (0-1) per NIP-39802 spec
- Align completion threshold to 95% to match filter behavior
- Skip invalid progress events with warning log

Improvements ensure consistency between completion detection and
filtering, while adding safety validation per the NIP spec.
This commit is contained in:
Gigi
2025-10-19 10:34:53 +02:00
parent 442c138d6a
commit 3b31eceeab
4 changed files with 14 additions and 5 deletions

View File

@@ -189,9 +189,10 @@ const ContentPanel: React.FC<ContentPanelProps> = ({
syncEnabled: settings?.syncReadingPosition,
onSave: handleSavePosition,
onReadingComplete: () => {
// Optional: Auto-mark as read when reading is complete
if (activeAccount && !isMarkedAsRead) {
// Could trigger auto-mark as read here if desired
// Auto-mark as read when reading is complete (if enabled in settings)
if (activeAccount && !isMarkedAsRead && settings?.autoMarkAsReadOnCompletion) {
console.log('📖 [ContentPanel] Auto-marking as read on completion')
handleMarkAsRead()
}
}
})