Fix mark message as read feature

This commit is contained in:
Mikołaj Pich 2018-11-06 19:11:30 +01:00
parent bd8f30d69a
commit 4e0ff49e0a
No known key found for this signature in database
GPG key ID: F62B26E36D4C4BAA
4 changed files with 10 additions and 5 deletions

View file

@ -116,7 +116,7 @@ class Api {
fun getDeletedMessages(startDate: LocalDateTime? = null, endDate: LocalDateTime? = null) = messages.getDeletedMessages(startDate, endDate)
fun getMessage(id: Int, folderId: Int, read: Boolean = false) = messages.getMessage(id, folderId, read)
fun getMessage(messageId: Int, folderId: Int, read: Boolean = false, id: Int? = null) = messages.getMessage(messageId, folderId, read, id)
fun getTimetable(startDate: LocalDate, endDate: LocalDate? = null) = snp.getTimetable(startDate, endDate)

View file

@ -70,8 +70,8 @@ class MessagesRepository(private val userId: Int, private val api: MessagesServi
.map { res -> res.data?.sortedBy { it.date } }
}
fun getMessage(id: Int, folderId: Int, read: Boolean): Single<Message> {
return api.getMessage(id, folderId, read).map { it.data }
fun getMessage(messageId: Int, folderId: Int, read: Boolean, id: Int?): Single<Message> {
return api.getMessage(messageId, folderId, read, id).map { it.data }
}
private fun getDate(date: LocalDateTime?): String {

View file

@ -26,5 +26,10 @@ interface MessagesService {
@POST("Wiadomosc.mvc/GetTrescWiadomosci")
@FormUrlEncoded
fun getMessage(@Field("idWiadomosc") id: Int, @Field("Folder") folderId: Int, @Field("Nieprzeczytana") read: Boolean): Single<MessagesResponse<Message>>
fun getMessage(
@Field("idWiadomosc") messageId: Int,
@Field("Folder") folderId: Int,
@Field("Nieprzeczytana") read: Boolean,
@Field("idWiadomoscAdresat") id: Int?
): Single<MessagesResponse<Message>>
}

View file

@ -54,7 +54,7 @@ class MessagesTest : BaseTest() {
server.enqueue(MockResponse().setBody(MessagesTest::class.java.getResource("Wiadomosc.json").readText()))
server.start(3000)
assertEquals(27214, api.getMessage(1, 1, false).blockingGet().id)
assertEquals(27214, api.getMessage(1, 1, false, 0).blockingGet().id)
}
@After