ChatRouter: Remember last selected channel
This change ensures that the last selected channel remains highlighted in the channel list even when navigating to other screens like server settings. The `lastSelectedChannelId` is updated whenever a channel destination is navigated to. This stored ID is then used to determine the `selectedChannelId` for the `ServerChannels` composable, ensuring the correct channel remains visually selected.
This commit is contained in:
parent
da28d50b18
commit
b1eb411ad4
|
|
@ -164,6 +164,7 @@ class ChatRouterViewModel @Inject constructor(
|
|||
var currentDestination by mutableStateOf<ChatRouterDestination>(ChatRouterDestination.default)
|
||||
var previousDestination by mutableStateOf<ChatRouterDestination?>(null)
|
||||
var lastNonChannelDestination by mutableStateOf<ChatRouterDestination?>(null)
|
||||
var lastSelectedChannelId by mutableStateOf<String?>(null)
|
||||
var latestChangelogRead by mutableStateOf(true)
|
||||
var latestChangelog by mutableStateOf("")
|
||||
var latestChangelogBody by mutableStateOf("")
|
||||
|
|
@ -226,6 +227,8 @@ class ChatRouterViewModel @Inject constructor(
|
|||
currentDestination = destination
|
||||
if (destination !is ChatRouterDestination.Channel) {
|
||||
lastNonChannelDestination = destination
|
||||
} else {
|
||||
lastSelectedChannelId = destination.channelId
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1105,7 +1108,7 @@ fun ChannelNavigator(
|
|||
is ChatRouterDestination.Channel -> currentServer
|
||||
else -> null
|
||||
},
|
||||
selectedChannelId = (if (dest is ChatRouterDestination.Channel) dest.channelId else null),
|
||||
selectedChannelId = viewModel.lastSelectedChannelId,
|
||||
navigateToServer = viewModel::navigateToServer,
|
||||
onShowServerContextSheet = onShowServerContextSheet,
|
||||
showSettingsIcon = isTouchExplorationEnabled,
|
||||
|
|
|
|||
Loading…
Reference in New Issue