fix: unusable server when stale data in kv

Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
Infi 2024-10-26 02:23:01 +02:00
parent a9da1068b3
commit d8eac62253
1 changed files with 2 additions and 1 deletions

View File

@ -185,8 +185,9 @@ class ChatRouterViewModel @Inject constructor(
val savedLastChannel = kvStorage.get("lastChannel/$serverId")
val channelId =
savedLastChannel ?: RevoltAPI.serverCache[serverId]?.channels?.firstOrNull()
val channelExists = RevoltAPI.channelCache.containsKey(channelId)
if (channelId != null) {
if (channelId != null && channelExists) {
setSaveDestination(ChatRouterDestination.Channel(channelId))
} else {
setSaveDestination(ChatRouterDestination.NoCurrentChannel(serverId))