Use enum directly instead of its value.

This commit is contained in:
Onuray Sahin 2020-09-28 19:05:33 +03:00 committed by Benoit Marty
parent 430a0d2492
commit e21f306635
3 changed files with 6 additions and 5 deletions

View File

@ -55,7 +55,7 @@ internal class DefaultSearchTask @Inject constructor(
searchCategories = SearchRequestCategories(
roomEvents = SearchRequestRoomEvents(
searchTerm = params.searchTerm,
orderBy = if (params.orderByRecent) SearchRequestOrder.RECENT.value else SearchRequestOrder.RANK.value,
orderBy = if (params.orderByRecent) SearchRequestOrder.RECENT else SearchRequestOrder.RANK,
filter = SearchRequestFilter(
limit = params.limit,
rooms = listOf(params.roomId)

View File

@ -17,13 +17,14 @@
package org.matrix.android.sdk.internal.session.search.request
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* Represents the order in which to search for results.
*/
@JsonClass(generateAdapter = false)
internal enum class SearchRequestOrder(val value: String) {
RANK("rank"),
RECENT("recent")
internal enum class SearchRequestOrder {
@Json(name = "rank") RANK,
@Json(name = "recent") RECENT
}

View File

@ -29,7 +29,7 @@ internal data class SearchRequestRoomEvents(
val filter: SearchRequestFilter? = null,
// By default, this is "rank". One of: ["recent", "rank"]
@Json(name = "order_by")
val orderBy: String? = null,
val orderBy: SearchRequestOrder? = null,
// Configures whether any context for the events returned are included in the response.
@Json(name = "event_context")
val eventContext: SearchRequestEventContext? = null