Compare commits

..

3 Commits

2 changed files with 13 additions and 40 deletions

View File

@ -1017,7 +1017,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
Toast.makeText(this, R.string.refresh_in_progress, Toast.LENGTH_SHORT).show()
// TODO: Use Dispatchers.IO
CoroutineScope(Dispatchers.Main).launch {
repository.offlineOverride = false
val updatedRemote = repository.updateRemote()
if (updatedRemote) {
// TODO: Send toast messages from the repository

View File

@ -178,13 +178,9 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails
return success
}
suspend fun markAsReadById(id: Int): Boolean {
var success = false
if (isNetworkAvailable()) {
success = api.markAsRead(id.toString())?.isSuccess == true
}
return success
}
suspend fun markAsReadById(id: Int): Boolean =
isNetworkAvailable() && api.markAsRead(id.toString())?.isSuccess == true
suspend fun unmarkAsRead(item: SelfossModel.Item): Boolean {
val success = unmarkAsReadById(item.id)
@ -195,13 +191,8 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails
return success
}
suspend fun unmarkAsReadById(id: Int): Boolean {
var success = false
if (isNetworkAvailable()) {
success = api.unmarkAsRead(id.toString())?.isSuccess == true
}
return success
}
suspend fun unmarkAsReadById(id: Int): Boolean =
isNetworkAvailable() && api.unmarkAsRead(id.toString())?.isSuccess == true
suspend fun starr(item: SelfossModel.Item): Boolean {
val success = starrById(item.id)
@ -212,13 +203,8 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails
return success
}
suspend fun starrById(id: Int): Boolean {
var success = false
if (isNetworkAvailable()) {
success = api.starr(id.toString())?.isSuccess == true
}
return success
}
suspend fun starrById(id: Int): Boolean =
isNetworkAvailable() && api.starr(id.toString())?.isSuccess == true
suspend fun unstarr(item: SelfossModel.Item): Boolean {
val success = unstarrById(item.id)
@ -229,22 +215,15 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails
return success
}
suspend fun unstarrById(id: Int): Boolean {
var success = false
if (isNetworkAvailable()) {
success = api.unstarr(id.toString())?.isSuccess == true
}
return success
}
suspend fun unstarrById(id: Int): Boolean =
isNetworkAvailable() && api.unstarr(id.toString())?.isSuccess == true
suspend fun markAllAsRead(items: ArrayList<SelfossModel.Item>): Boolean {
var success = false
if (isNetworkAvailable()) {
success = api.markAllAsRead(items.map { it.id.toString() })?.isSuccess == true
}
if (success) {
if (isNetworkAvailable() && api.markAllAsRead(items.map { it.id.toString() })?.isSuccess == true) {
success = true
for (item in items) {
markAsReadLocally(item)
}
@ -319,13 +298,8 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails
return success
}
suspend fun updateRemote(): Boolean {
var response = false
if (isConnectionAvailable.value) {
response = api.update()?.isSuccess == true
}
return response
}
suspend fun updateRemote(): Boolean =
isNetworkAvailable() && api.update()?.isSuccess == true
suspend fun login(): Boolean {
var result = false