Room tag: let the tag order be anything to avoid breaking at the moment.

This commit is contained in:
ganfra 2019-02-20 18:09:07 +01:00
parent 9cc2cf8360
commit ca890e1ef4
2 changed files with 5 additions and 4 deletions

View File

@ -21,5 +21,5 @@ import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true) @JsonClass(generateAdapter = true)
data class RoomTagContent( data class RoomTagContent(
@Json(name = "tags") val tags: Map<String, Map<String, Double>> = emptyMap() @Json(name = "tags") val tags: Map<String, Map<String, Any>> = emptyMap()
) )

View File

@ -32,15 +32,16 @@ internal class RoomTagHandler {
val tags = ArrayList<RoomTagEntity>() val tags = ArrayList<RoomTagEntity>()
for (tagName in content.tags.keys) { for (tagName in content.tags.keys) {
val params = content.tags[tagName] val params = content.tags[tagName]
val tag = if (params != null) { val order = params?.get("order")
RoomTagEntity(tagName, params["order"]) val tag = if (order is Double) {
RoomTagEntity(tagName, order)
} else { } else {
RoomTagEntity(tagName, null) RoomTagEntity(tagName, null)
} }
tags.add(tag) tags.add(tag)
} }
val roomSummaryEntity = RoomSummaryEntity.where(realm, roomId).findFirst() val roomSummaryEntity = RoomSummaryEntity.where(realm, roomId).findFirst()
?: RoomSummaryEntity(roomId) ?: RoomSummaryEntity(roomId)
roomSummaryEntity.tags.clear() roomSummaryEntity.tags.clear()
roomSummaryEntity.tags.addAll(tags) roomSummaryEntity.tags.addAll(tags)