mirror of https://github.com/Ashinch/ReadYou.git
feat(rss): support batch mark articles as read (#640)
This commit is contained in:
parent
7a90aa3a98
commit
df239022e7
|
@ -161,6 +161,14 @@ abstract class AbstractRssRepository(
|
|||
}
|
||||
}
|
||||
|
||||
open suspend fun batchMarkAsRead(articleIds: Set<String>, isUnread: Boolean) {
|
||||
val accountId = context.currentAccountId
|
||||
articleIds.takeIf { it.isNotEmpty() }?.chunked(500)?.forEachIndexed { index, it ->
|
||||
Log.d("RLog", "sync markAsRead: ${(index * 500) + it.size}/${articleIds.size} num")
|
||||
articleDao.markAsReadByIdSet(accountId, it.toSet(), isUnread)
|
||||
}
|
||||
}
|
||||
|
||||
open suspend fun markAsStarred(articleId: String, isStarred: Boolean) {
|
||||
val accountId = context.currentAccountId
|
||||
articleDao.markAsStarredByArticleId(accountId, articleId, isStarred)
|
||||
|
|
|
@ -323,6 +323,18 @@ class FeverRssService @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
override suspend fun batchMarkAsRead(articleIds: Set<String>, isUnread: Boolean) {
|
||||
super.batchMarkAsRead(articleIds, isUnread)
|
||||
val feverAPI = getFeverAPI()
|
||||
articleIds.takeIf { it.isNotEmpty() }?.forEachIndexed { index, it ->
|
||||
Log.d("RLog", "sync markAsRead: ${index}/${articleIds.size} num")
|
||||
feverAPI.markItem(
|
||||
status = if (isUnread) FeverDTO.StatusEnum.Unread else FeverDTO.StatusEnum.Read,
|
||||
id = it.dollarLast(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun markAsStarred(articleId: String, isStarred: Boolean) {
|
||||
super.markAsStarred(articleId, isStarred)
|
||||
val feverAPI = getFeverAPI()
|
||||
|
|
|
@ -476,8 +476,8 @@ class GoogleReaderRssService @Inject constructor(
|
|||
}
|
||||
}
|
||||
super.markAsRead(groupId, feedId, articleId, before, isUnread)
|
||||
markList.takeIf { it.isNotEmpty() }?.chunked(500)?.forEach {
|
||||
Log.d("RLog", "sync markAsRead: ${it.size} num")
|
||||
markList.takeIf { it.isNotEmpty() }?.chunked(500)?.forEachIndexed { index, it ->
|
||||
Log.d("RLog", "sync markAsRead: ${(index * 500) + it.size}/${markList.size} num")
|
||||
googleReaderAPI.editTag(
|
||||
itemIds = it,
|
||||
mark = if (!isUnread) GoogleReaderAPI.Stream.READ.tag else null,
|
||||
|
@ -486,6 +486,19 @@ class GoogleReaderRssService @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
override suspend fun batchMarkAsRead(articleIds: Set<String>, isUnread: Boolean) {
|
||||
super.batchMarkAsRead(articleIds, isUnread)
|
||||
val googleReaderAPI = getGoogleReaderAPI()
|
||||
articleIds.takeIf { it.isNotEmpty() }?.chunked(500)?.forEachIndexed { index, it ->
|
||||
Log.d("RLog", "sync markAsRead: ${(index * 500) + it.size}/${articleIds.size} num")
|
||||
googleReaderAPI.editTag(
|
||||
itemIds = it.map { it.dollarLast() },
|
||||
mark = if (!isUnread) GoogleReaderAPI.Stream.READ.tag else null,
|
||||
unmark = if (isUnread) GoogleReaderAPI.Stream.READ.tag else null,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun markAsStarred(articleId: String, isStarred: Boolean) {
|
||||
super.markAsStarred(articleId, isStarred)
|
||||
getGoogleReaderAPI().editTag(
|
||||
|
|
Loading…
Reference in New Issue