Skip to content

Commit 47261b9

Browse files
committed
fix(greader): stop sync from undoing mark all as read
markAsRead pushed only locally-known IDs via edit-tag, so unread items only on the server stayed unread and got flipped back on the next sync. Use the bulk mark-all-as-read endpoint instead.
1 parent 19d4973 commit 47261b9

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

app/src/main/java/me/ash/reader/domain/service/GoogleReaderRssService.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,26 @@ constructor(
773773
) {
774774
val accountId = accountService.getCurrentAccountId()
775775
val googleReaderAPI = getGoogleReaderAPI()
776+
777+
// The server can have unread items we don't have locally yet. Marking by ID
778+
// misses those, and the next sync flips them back to unread. Mark the whole
779+
// stream on the server instead using markAllAsRead.
780+
if (!isUnread && articleId == null) {
781+
val streamTag =
782+
when {
783+
groupId != null ->
784+
GoogleReaderAPI.Stream.Category(groupId.dollarLast()).tag
785+
feedId != null -> GoogleReaderAPI.Stream.Feed(feedId.dollarLast()).tag
786+
else -> GoogleReaderAPI.Stream.AllItems.tag
787+
}
788+
super.markAsRead(groupId, feedId, articleId, before, isUnread)
789+
googleReaderAPI.markAllAsRead(
790+
streamId = streamTag,
791+
sinceTimestamp = before?.time?.times(1000L),
792+
)
793+
return
794+
}
795+
776796
val markList: List<String> =
777797
when {
778798
groupId != null -> {

0 commit comments

Comments
 (0)