Correct order of items in grid view

Signed-off-by: Tim Krüger <t@timkrueger.me>
This commit is contained in:
Tim Krüger 2022-04-26 12:13:41 +02:00
parent a1b7e1260c
commit 53a1725606
No known key found for this signature in database
GPG key ID: FECE3A7222C52A4E

View file

@ -34,7 +34,7 @@ class SharedItemsViewModel(private val repository: SharedItemsRepository) : View
?.subscribe(object : Observer<Response<ChatShareOverall>> {
var chatLastGiven: String = ""
val items = mutableListOf<SharedItem>()
val items = mutableMapOf<String, SharedItem>()
override fun onSubscribe(d: Disposable) = Unit
@ -47,13 +47,11 @@ class SharedItemsViewModel(private val repository: SharedItemsRepository) : View
val previewAvailable = "yes".equals(fileParameters["preview-available"]!!, ignoreCase = true)
items.add(
SharedItem(
fileParameters["id"]!!, fileParameters["name"]!!,
fileParameters["mimetype"]!!, fileParameters["link"]!!,
previewAvailable,
repository.previewLink(fileParameters["id"])
)
items[it.value.id] = SharedItem(
fileParameters["id"]!!, fileParameters["name"]!!,
fileParameters["mimetype"]!!, fileParameters["link"]!!,
previewAvailable,
repository.previewLink(fileParameters["id"])
)
}
}
@ -64,7 +62,7 @@ class SharedItemsViewModel(private val repository: SharedItemsRepository) : View
override fun onComplete() {
this@SharedItemsViewModel._media.value =
SharedMediaItems(items.asReversed(), chatLastGiven, repository.authHeader())
SharedMediaItems(items.toSortedMap().values.toList().reversed(), chatLastGiven, repository.authHeader())
}
})
}