diff --git a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt index 541425c..28fd2d6 100644 --- a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt +++ b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt @@ -156,10 +156,10 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap } // TODO: Add tests - suspend fun getSpouts(): Map? { + suspend fun getSpouts(): Map { return if (isNetworkAvailable()) { val spouts = api.spouts() - return if (spouts.success && spouts.data != null) { + if (spouts.success && spouts.data != null) { spouts.data } else { emptyMap() // TODO: do something here @@ -193,7 +193,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap private suspend fun markAsReadById(id: Int): Boolean { return if (isNetworkAvailable()) { - api.markAsRead(id.toString())?.isSuccess + api.markAsRead(id.toString()).isSuccess } else { insertDBAction(id.toString(), read = true) true @@ -212,7 +212,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap private suspend fun unmarkAsReadById(id: Int): Boolean { return if (isNetworkAvailable()) { - api.unmarkAsRead(id.toString())?.isSuccess + api.unmarkAsRead(id.toString()).isSuccess } else { insertDBAction(id.toString(), unread = true) true @@ -231,7 +231,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap private suspend fun starrById(id: Int): Boolean { return if (isNetworkAvailable()) { - api.starr(id.toString())?.isSuccess + api.starr(id.toString()).isSuccess } else { insertDBAction(id.toString(), starred = true) true @@ -250,7 +250,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap private suspend fun unstarrById(id: Int): Boolean { return if (isNetworkAvailable()) { - api.unstarr(id.toString())?.isSuccess + api.unstarr(id.toString()).isSuccess } else { insertDBAction(id.toString(), starred = true) true @@ -261,7 +261,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap suspend fun markAllAsRead(items: ArrayList): Boolean { var success = false - if (isNetworkAvailable() && api.markAllAsRead(items.map { it.id.toString() })?.isSuccess) { + if (isNetworkAvailable() && api.markAllAsRead(items.map { it.id.toString() }).isSuccess) { success = true for (item in items) { markAsReadLocally(item) @@ -330,7 +330,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap tags, filter, appSettingsService.getApiVersion() - )?.isSuccess == true + ).isSuccess == true } return response @@ -340,9 +340,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap var success = false if (isNetworkAvailable()) { val response = api.deleteSource(id) - if (response != null) { - success = response.isSuccess - } + success = response.isSuccess } return success @@ -350,7 +348,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap suspend fun updateRemote(): Boolean { return if (isNetworkAvailable()) { - api.update()?.equals("finished") + api.update().equals("finished") } else { false } @@ -361,7 +359,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap if (isNetworkAvailable()) { try { val response = api.login() - result = response?.isSuccess == true + result = response.isSuccess == true if (result) { updateApiVersion() }