Skip to content

Commit

Permalink
fix: don't mark document as read if user does not confirm reception o…
Browse files Browse the repository at this point in the history
…f it
  • Loading branch information
thoreyjona committed Oct 10, 2024
1 parent 5eb2885 commit 1326370
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions apps/native/app/src/screens/document-detail/document-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ export const DocumentDetailScreen: NavigationFunctionComponent<{
setShowConfirmedAlert(true)
}
} finally {
markDocumentAsRead()
setRefetching(false)
}
}
Expand Down Expand Up @@ -356,11 +357,10 @@ export const DocumentDetailScreen: NavigationFunctionComponent<{
setVisible(true)
})

useEffect(() => {
const markDocumentAsRead = () => {
if (Document.opened) {
return
}

// Let's mark the document as read in the cache and decrease unreadCount if it is not 0
client.cache.modify({
id: client.cache.identify({
Expand All @@ -383,6 +383,13 @@ export const DocumentDetailScreen: NavigationFunctionComponent<{
},
},
})
}

useEffect(() => {
if (Document.opened || !shouldIncludeDocument) {
return
}
markDocumentAsRead()
}, [Document.id])

useEffect(() => {
Expand Down

0 comments on commit 1326370

Please sign in to comment.