Fix sources tests

This commit is contained in:
2022-09-28 18:45:21 +02:00
parent 219cae5d74
commit d311c2cdeb
2 changed files with 108 additions and 53 deletions

View File

@@ -171,15 +171,17 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
}
}
suspend fun getSources(): ArrayList<SelfossModel.Source>? {
suspend fun getSources(): ArrayList<SelfossModel.Source> {
return if (isNetworkAvailable()) {
val apiSources = api.sources()
if (apiSources.success && apiSources.data != null && (appSettingsService.isItemCachingEnabled() || !appSettingsService.isUpdateSourcesEnabled())) {
if (apiSources.success && apiSources.data != null && (appSettingsService.isItemCachingEnabled() || appSettingsService.isUpdateSourcesEnabled())) {
resetDBSourcesWithData(apiSources.data)
}
apiSources.data
} else {
apiSources.data ?: ArrayList()
} else if (appSettingsService.isItemCachingEnabled() || appSettingsService.isUpdateSourcesEnabled()) {
ArrayList(getDBSources().map { it.toView() })
} else {
ArrayList()
}
}