Skip to content

Commit

Permalink
[optimize] Optimize update RSS strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyD666 committed Sep 12, 2024
1 parent 1886800 commit 54f9f1c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 22,7 @@ android {
minSdk = 24
targetSdk = 35
versionCode = 24
versionName = "2.1-beta02"
versionName = "2.1-beta03"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 13,7 @@ import com.skyd.anivu.model.bean.article.ArticleBean
import com.skyd.anivu.model.bean.article.ArticleWithFeed
import com.skyd.anivu.model.db.dao.ArticleDao
import com.skyd.anivu.model.db.dao.FeedDao
import com.skyd.anivu.ui.component.showToast
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
Expand Down Expand Up @@ -96,12 97,17 @@ class ArticleRepository @Inject constructor(
feedUrls.forEach { feedUrl ->
requests = async {
val articleBeanListAsync = async {
rssHelper.queryRssXml(
feed = feedDao.getFeed(feedUrl),
latestLink = articleDao.queryLatestByFeedUrl(feedUrl)?.link,
)?.also { feedWithArticle ->
feedDao.updateFeed(feedWithArticle.feed)
}?.articles
runCatching {
rssHelper.queryRssXml(
feed = feedDao.getFeed(feedUrl),
latestLink = articleDao.queryLatestByFeedUrl(feedUrl)?.link,
)?.also { feedWithArticle ->
feedDao.updateFeed(feedWithArticle.feed)
}?.articles
}.onFailure { e ->
e.printStackTrace()
(feedUrl "\n" e.message).showToast()
}.getOrNull()
}
val articleBeanList = articleBeanListAsync.await() ?: return@async

Expand Down

0 comments on commit 54f9f1c

Please sign in to comment.