fix: download recent news
This commit is contained in:
@@ -22,6 +22,9 @@ interface NewsDao {
|
|||||||
@Query("SELECT * FROM newsDB ORDER BY `publishedAt` DESC")
|
@Query("SELECT * FROM newsDB ORDER BY `publishedAt` DESC")
|
||||||
fun paging(): PagingSource<Int, NewsDB>
|
fun paging(): PagingSource<Int, NewsDB>
|
||||||
|
|
||||||
|
@Query("DELETE FROM newsDB")
|
||||||
|
suspend fun clear()
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
suspend fun insertAll(news: List<NewsDB>)
|
suspend fun insertAll(news: List<NewsDB>)
|
||||||
|
|
||||||
|
|||||||
@@ -64,9 +64,9 @@ class NewsRemoteMediator(
|
|||||||
}
|
}
|
||||||
|
|
||||||
db.withTransaction {
|
db.withTransaction {
|
||||||
// if (loadType == LoadType.REFRESH) {
|
if (loadType == LoadType.REFRESH) {
|
||||||
// db.newsDao().clear()
|
db.newsDao().clear()
|
||||||
// }
|
}
|
||||||
|
|
||||||
db.newsDao().insertAll(
|
db.newsDao().insertAll(
|
||||||
news.map { it.toEntity() }
|
news.map { it.toEntity() }
|
||||||
|
|||||||
Reference in New Issue
Block a user