Don't reset QS tile entity when changing servers if existing on new server (#3530)

- Prevent unnecessary changes to the selected entity when changing servers, if an entity exists on both servers. It already didn't clear everything like title/icon, just the selected entity!
 - Still calling selectEntityId in case the icon is different
This commit is contained in:
Joris Pelgröm 2023-05-20 20:56:45 +02:00 committed by GitHub
parent d81913b7ea
commit 6cf6c06c4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -244,10 +244,10 @@ class ManageTilesViewModel @Inject constructor(
}
fun selectServerId(serverId: Int) {
val resetEntity = serverId != selectedServerId
val resetEntity = serverId != selectedServerId && entities[serverId]?.none { it.entityId == selectedEntityId } == true
selectedServerId = serverId
loadEntities(serverId)
if (resetEntity) selectEntityId("")
selectEntityId(if (resetEntity) "" else selectedEntityId)
}
private fun loadEntities(serverId: Int) {