Skip to content

Commit

Permalink
Add update read status to alert interface (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivnsch authored Jul 30, 2020
1 parent 2c58dcc commit ccd9ea4
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import org.coepi.core.jni.asResult
interface AlertsApi {
fun fetchNewAlerts(): Result<List<Alert>, Throwable>
fun deleteAlert(id: String): Result<Unit, Throwable>
fun updateIsRead(id: String, isRead: Boolean): Result<Unit, Throwable>
}

class AlertsFetcherImpl(private val api: JniApi) :
AlertsApi {
class AlertsFetcherImpl(private val api: JniApi) : AlertsApi {

override fun fetchNewAlerts(): Result<List<Alert>, Throwable> {
val result = api.fetchNewReports()
Expand All @@ -34,6 +34,9 @@ class AlertsFetcherImpl(private val api: JniApi) :
override fun deleteAlert(id: String): Result<Unit, Throwable> =
api.deleteAlert(id).asResult()

override fun updateIsRead(id: String, isRead: Boolean): Result<Unit, Throwable> =
api.updateAlertIsRead(id, if (isRead) 1 else 0).asResult()

private fun JniAlertsArrayResult.statusDescription(): String =
statusDescription(status, message)

Expand Down

0 comments on commit ccd9ea4

Please sign in to comment.