Skip to content

Commit

Permalink
fix(mobile): no marking read when no scrolling (#2913)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban authored Feb 28, 2025
1 parent 34540a1 commit cd576ff
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions apps/mobile/src/modules/entry-list/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function useOnViewableItemsChanged({
}: {
idExtractor?: (item: ViewToken) => string
} = {}) {
const orientation = useRef<"down" | "up">("down")
const orientation = useRef<"down" | "up" | "initial">("initial")
const lastOffset = useRef(0)

const markAsReadWhenScrolling = useGeneralSettingKey("scrollMarkUnread")
Expand All @@ -26,15 +26,17 @@ export function useOnViewableItemsChanged({
}) => void = useNonReactiveCallback(({ viewableItems, changed }) => {
debouncedFetchEntryContentByStream(viewableItems.map((item) => stableIdExtractor(item)))

if (markAsReadWhenScrolling && orientation.current === "down") {
if (orientation.current !== "down") return

if (markAsReadWhenScrolling) {
changed
.filter((item) => !item.isViewable)
.forEach((item) => {
unreadSyncService.markEntryAsRead(stableIdExtractor(item))
})
}

if (markAsReadWhenRendering && orientation.current === "down") {
if (markAsReadWhenRendering) {
viewableItems.forEach((item) => {
unreadSyncService.markEntryAsRead(stableIdExtractor(item))
})
Expand Down

0 comments on commit cd576ff

Please sign in to comment.