fix: unusable server when stale data in kv
Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
parent
a9da1068b3
commit
d8eac62253
|
|
@ -185,8 +185,9 @@ class ChatRouterViewModel @Inject constructor(
|
||||||
val savedLastChannel = kvStorage.get("lastChannel/$serverId")
|
val savedLastChannel = kvStorage.get("lastChannel/$serverId")
|
||||||
val channelId =
|
val channelId =
|
||||||
savedLastChannel ?: RevoltAPI.serverCache[serverId]?.channels?.firstOrNull()
|
savedLastChannel ?: RevoltAPI.serverCache[serverId]?.channels?.firstOrNull()
|
||||||
|
val channelExists = RevoltAPI.channelCache.containsKey(channelId)
|
||||||
|
|
||||||
if (channelId != null) {
|
if (channelId != null && channelExists) {
|
||||||
setSaveDestination(ChatRouterDestination.Channel(channelId))
|
setSaveDestination(ChatRouterDestination.Channel(channelId))
|
||||||
} else {
|
} else {
|
||||||
setSaveDestination(ChatRouterDestination.NoCurrentChannel(serverId))
|
setSaveDestination(ChatRouterDestination.NoCurrentChannel(serverId))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue