Handle case when message details response body is null

This commit is contained in:
Mikołaj Pich 2024-03-24 20:05:29 +01:00
parent b4941cb70a
commit 44c31fa0d5
No known key found for this signature in database
2 changed files with 2 additions and 2 deletions

View file

@ -88,7 +88,7 @@ internal class MessagesRepository(
}
suspend fun getMessageDetails(globalKey: String, markAsRead: Boolean): MessageDetails {
val details = api.getMessageDetails(globalKey)
val details = api.getMessageDetails(globalKey) ?: error("Message not exist")
if (markAsRead) {
runCatching {
loginModule()

View file

@ -75,7 +75,7 @@ internal interface MessagesService {
): List<MessageMeta>
@GET("api/WiadomoscSzczegoly")
suspend fun getMessageDetails(@Query("apiGlobalKey") globalKey: String): MessageDetails
suspend fun getMessageDetails(@Query("apiGlobalKey") globalKey: String): MessageDetails?
@PUT("api/WiadomoscSzczegoly")
suspend fun markMessageAsRead(@Body body: Map<String, String>)