mirror of
https://github.com/gedoor/legado.git
synced 2025-01-08 11:47:32 +08:00
优化rss加载逻辑 (#4286)
This commit is contained in:
parent
7523ffa318
commit
1c0a7bc7b4
@ -23,6 +23,9 @@ interface RssArticleDao {
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun insert(vararg rssArticle: RssArticle)
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
||||
fun append(vararg rssArticle: RssArticle)
|
||||
|
||||
@Query("delete from rssArticles where origin = :origin and sort = :sort and `order` < :order")
|
||||
fun clearOld(origin: String, sort: String, order: Long)
|
||||
|
||||
|
@ -80,14 +80,16 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application
|
||||
return
|
||||
}
|
||||
val firstArticle = articles.first()
|
||||
val dbArticle = appDb.rssArticleDao.get(firstArticle.origin, firstArticle.link)
|
||||
if (dbArticle != null) {
|
||||
val dbFirstArticle = appDb.rssArticleDao.get(firstArticle.origin, firstArticle.link)
|
||||
val lastArticle = articles.last()
|
||||
val dbLastArticle = appDb.rssArticleDao.get(lastArticle.origin, lastArticle.link)
|
||||
if (dbFirstArticle != null && dbLastArticle != null) {
|
||||
loadFinallyLiveData.postValue(false)
|
||||
} else {
|
||||
articles.forEach {
|
||||
it.order = order--
|
||||
}
|
||||
appDb.rssArticleDao.insert(*articles.toTypedArray())
|
||||
appDb.rssArticleDao.append(*articles.toTypedArray())
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user