feat(mobile): render as read (#2835)

This commit is contained in:
Stephen Zhou 2025-02-21 10:37:22 +08:00 committed by GitHub
parent cc51d861c9
commit c0afb39788
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 1 deletions

View File

@ -10,6 +10,7 @@ export function useOnViewableItemsChanged(
idExtractor: (item: ViewToken) => string = defaultIdExtractor,
): (info: { viewableItems: ViewToken[]; changed: ViewToken[] }) => void {
const markAsReadWhenScrolling = useGeneralSettingKey("scrollMarkUnread")
const markAsReadWhenRendering = useGeneralSettingKey("renderMarkUnread")
const [stableIdExtractor] = useState(() => idExtractor)
@ -23,7 +24,15 @@ export function useOnViewableItemsChanged(
unreadSyncService.markEntryAsRead(stableIdExtractor(item))
})
}
if (markAsReadWhenRendering) {
viewableItems
.filter((item) => item.isViewable)
.forEach((item) => {
unreadSyncService.markEntryAsRead(stableIdExtractor(item))
})
}
},
[markAsReadWhenScrolling, stableIdExtractor],
[markAsReadWhenRendering, markAsReadWhenScrolling, stableIdExtractor],
)
}