fix(rss): ignore starred articles by default when clean feed or group (#652)

This commit is contained in:
Ash 2024-03-18 16:49:09 +08:00 committed by GitHub
parent 69d7124a76
commit 90859947ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 9 deletions

View File

@ -370,9 +370,10 @@ interface ArticleDao {
DELETE FROM article DELETE FROM article
WHERE accountId = :accountId WHERE accountId = :accountId
AND feedId = :feedId AND feedId = :feedId
AND (isStarred = :includeStarred OR :includeStarred = 1)
""" """
) )
suspend fun deleteByFeedId(accountId: Int, feedId: String) suspend fun deleteByFeedId(accountId: Int, feedId: String, includeStarred: Boolean = false)
@Query( @Query(
""" """
@ -383,10 +384,11 @@ interface ArticleDao {
AND a.feedId = b.id AND a.feedId = b.id
AND b.groupId = c.id AND b.groupId = c.id
AND c.id = :groupId AND c.id = :groupId
AND (a.isStarred = :includeStarred OR :includeStarred = 1)
) )
""" """
) )
suspend fun deleteByGroupId(accountId: Int, groupId: String) suspend fun deleteByGroupId(accountId: Int, groupId: String, includeStarred: Boolean = false)
@Query( @Query(
""" """

View File

@ -334,7 +334,7 @@ abstract class AbstractRssRepository(
) { ) {
return return
} }
deleteArticles(group = group) deleteArticles(group = group, includeStarred = true)
feedDao.deleteByGroupId(accountId, group.id) feedDao.deleteByGroupId(accountId, group.id)
groupDao.delete(group) groupDao.delete(group)
} }
@ -345,14 +345,14 @@ abstract class AbstractRssRepository(
) { ) {
return return
} }
deleteArticles(feed = feed) deleteArticles(feed = feed, includeStarred = true)
feedDao.delete(feed) feedDao.delete(feed)
} }
suspend fun deleteArticles(group: Group? = null, feed: Feed? = null) { suspend fun deleteArticles(group: Group? = null, feed: Feed? = null, includeStarred: Boolean = false) {
when { when {
group != null -> articleDao.deleteByGroupId(context.currentAccountId, group.id) group != null -> articleDao.deleteByGroupId(context.currentAccountId, group.id, includeStarred)
feed != null -> articleDao.deleteByFeedId(context.currentAccountId, feed.id) feed != null -> articleDao.deleteByFeedId(context.currentAccountId, feed.id, includeStarred)
} }
} }

View File

@ -83,14 +83,14 @@ class FeverAPI private constructor(
postRequest<FeverDTO.ItemsByStarred>("saved_item_ids").apply { checkAuth(auth) } postRequest<FeverDTO.ItemsByStarred>("saved_item_ids").apply { checkAuth(auth) }
suspend fun markItem(status: FeverDTO.StatusEnum, id: String): FeverDTO.Common = suspend fun markItem(status: FeverDTO.StatusEnum, id: String): FeverDTO.Common =
postRequest<FeverDTO.Common>("&mark=item&as=${status.value}&id=$id").apply { checkAuth(auth) } postRequest<FeverDTO.Common>("mark=item&as=${status.value}&id=$id").apply { checkAuth(auth) }
private suspend fun markFeedOrGroup( private suspend fun markFeedOrGroup(
act: String, act: String,
status: FeverDTO.StatusEnum, status: FeverDTO.StatusEnum,
id: Long, id: Long,
before: Long, before: Long,
): FeverDTO.Common = postRequest<FeverDTO.Common>("&mark=$act&as=${status.value}&id=$id&before=$before") ): FeverDTO.Common = postRequest<FeverDTO.Common>("mark=$act&as=${status.value}&id=$id&before=$before")
.apply { checkAuth(auth) } .apply { checkAuth(auth) }
suspend fun markGroup(status: FeverDTO.StatusEnum, id: Long, before: Long) = suspend fun markGroup(status: FeverDTO.StatusEnum, id: Long, before: Long) =