Make synchronization aware of subFilters (Folder/Feed) in TimelineTab
* Only for local accounts
This commit is contained in:
parent
32e0c17e08
commit
0aced64faf
appcompose/src
androidTest/java/com/readrops/app/compose
main/java/com/readrops/app/compose
db/src/main/java/com/readrops/db/dao/newdao
@ -85,7 +85,7 @@ class LocalRSSRepositoryTest : KoinTest {
|
||||
.setBody(Buffer().readFrom(stream))
|
||||
)
|
||||
|
||||
val result = repository.synchronize(null) {
|
||||
val result = repository.synchronize(listOf()) {
|
||||
assertEquals(it.name, feeds.first().name)
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ abstract class ARepository(
|
||||
* and errors per feed if occurred to be transmitted to the user
|
||||
*/
|
||||
abstract suspend fun synchronize(
|
||||
selectedFeeds: List<Feed>?,
|
||||
selectedFeeds: List<Feed>,
|
||||
onUpdate: (Feed) -> Unit
|
||||
): Pair<SyncResult, ErrorResult>
|
||||
|
||||
|
@ -27,15 +27,15 @@ class LocalRSSRepository(
|
||||
}
|
||||
|
||||
override suspend fun synchronize(
|
||||
selectedFeeds: List<Feed>?,
|
||||
selectedFeeds: List<Feed>,
|
||||
onUpdate: (Feed) -> Unit
|
||||
): Pair<SyncResult, ErrorResult> {
|
||||
val errors = mutableMapOf<Feed, Exception>()
|
||||
val syncResult = SyncResult()
|
||||
|
||||
val feeds = if (selectedFeeds.isNullOrEmpty()) {
|
||||
val feeds = selectedFeeds.ifEmpty {
|
||||
database.newFeedDao().selectFeeds(account.id)
|
||||
} else selectedFeeds
|
||||
}
|
||||
|
||||
for (feed in feeds) {
|
||||
onUpdate(feed)
|
||||
|
@ -81,10 +81,20 @@ class TimelineScreenModel(
|
||||
|
||||
fun refreshTimeline() {
|
||||
_timelineState.update { it.copy(isRefreshing = true) }
|
||||
screenModelScope.launch(dispatcher) {
|
||||
repository?.synchronize(null) {
|
||||
|
||||
}
|
||||
screenModelScope.launch(dispatcher) {
|
||||
val selectedFeeds = if (currentAccount!!.isLocal) {
|
||||
when (filters.value.subFilter) {
|
||||
SubFilter.FEED -> listOf(database.newFeedDao().selectFeed(filters.value.filterFeedId))
|
||||
SubFilter.FOLDER -> database.newFeedDao().selectFeedsByFolder(filters.value.filterFolderId)
|
||||
else -> listOf()
|
||||
}
|
||||
} else listOf()
|
||||
|
||||
repository?.synchronize(
|
||||
selectedFeeds = selectedFeeds,
|
||||
onUpdate = { }
|
||||
)
|
||||
|
||||
_timelineState.update {
|
||||
it.copy(
|
||||
|
@ -12,8 +12,11 @@ import kotlinx.coroutines.flow.Flow
|
||||
@Dao
|
||||
abstract class NewFeedDao : NewBaseDao<Feed> {
|
||||
|
||||
@Query("Select * From Feed")
|
||||
abstract fun selectFeeds(): Flow<List<Feed>>
|
||||
@Query("Select * From Feed Where id = :feedId")
|
||||
abstract suspend fun selectFeed(feedId: Int): Feed
|
||||
|
||||
@Query("Select * From Feed Where folder_id = :folderId")
|
||||
abstract suspend fun selectFeedsByFolder(folderId: Int): List<Feed>
|
||||
|
||||
@Query("Select * from Feed Where account_id = :accountId order by name ASC")
|
||||
abstract suspend fun selectFeeds(accountId: Int): List<Feed>
|
||||
|
Loading…
x
Reference in New Issue
Block a user