From ccd9ea4b792a2eea7180e3bb33e451faafa6626d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Sch=C3=BCtz?= Date: Thu, 30 Jul 2020 18:27:49 +0200 Subject: [PATCH] Add update read status to alert interface (#142) --- .../src/main/java/org/coepi/core/services/AlertsApi.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/android/core/core/src/main/java/org/coepi/core/services/AlertsApi.kt b/android/core/core/src/main/java/org/coepi/core/services/AlertsApi.kt index 4901d24..5c20f37 100644 --- a/android/core/core/src/main/java/org/coepi/core/services/AlertsApi.kt +++ b/android/core/core/src/main/java/org/coepi/core/services/AlertsApi.kt @@ -18,10 +18,10 @@ import org.coepi.core.jni.asResult interface AlertsApi { fun fetchNewAlerts(): Result, Throwable> fun deleteAlert(id: String): Result + fun updateIsRead(id: String, isRead: Boolean): Result } -class AlertsFetcherImpl(private val api: JniApi) : - AlertsApi { +class AlertsFetcherImpl(private val api: JniApi) : AlertsApi { override fun fetchNewAlerts(): Result, Throwable> { val result = api.fetchNewReports() @@ -34,6 +34,9 @@ class AlertsFetcherImpl(private val api: JniApi) : override fun deleteAlert(id: String): Result = api.deleteAlert(id).asResult() + override fun updateIsRead(id: String, isRead: Boolean): Result = + api.updateAlertIsRead(id, if (isRead) 1 else 0).asResult() + private fun JniAlertsArrayResult.statusDescription(): String = statusDescription(status, message)