Refactor: Clean up ChatRouterScreen and ChannelSideDrawer
- Removed `asSerialisedString()` function and `defaultForDMList` from `ChatRouterScreen.kt` as they were unused. - Simplified `navigateToServer` in `ChatRouterScreen.kt` by removing logic to fetch and validate the last channel. - Removed unused imports and `serverInfoOffset` from `ChannelSideDrawer.kt`.
This commit is contained in:
parent
2c173087a5
commit
f2301c6760
|
|
@ -1,9 +1,7 @@
|
|||
package chat.revolt.composables.screens.chat.drawer
|
||||
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.animateColorAsState
|
||||
import androidx.compose.animation.core.Spring
|
||||
import androidx.compose.animation.core.VisibilityThreshold
|
||||
import androidx.compose.animation.core.animateDpAsState
|
||||
import androidx.compose.animation.core.animateFloatAsState
|
||||
import androidx.compose.animation.core.spring
|
||||
|
|
@ -30,7 +28,6 @@ import androidx.compose.foundation.layout.offset
|
|||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.requiredSize
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.statusBars
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.LazyListState
|
||||
|
|
@ -69,7 +66,6 @@ import androidx.compose.ui.res.stringResource
|
|||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import chat.revolt.R
|
||||
|
|
@ -95,9 +91,7 @@ import chat.revolt.composables.generic.presenceFromStatus
|
|||
import chat.revolt.composables.screens.chat.ChannelIcon
|
||||
import chat.revolt.composables.screens.chat.discover.DiscoverServersList
|
||||
import chat.revolt.screens.chat.ChatRouterDestination
|
||||
import chat.revolt.screens.chat.LocalIsConnected
|
||||
import chat.revolt.sheets.ChannelContextSheet
|
||||
import com.google.android.material.color.MaterialColors
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
|
|
@ -153,17 +147,6 @@ fun ChannelSideDrawer(
|
|||
), label = "Server banner height"
|
||||
)
|
||||
|
||||
val serverInfoOffset by animateDpAsState(
|
||||
if (LocalIsConnected.current)
|
||||
WindowInsets.statusBars.asPaddingValues().calculateTopPadding()
|
||||
else
|
||||
0.dp,
|
||||
animationSpec = spring(
|
||||
stiffness = Spring.StiffnessMediumLow,
|
||||
visibilityThreshold = Dp.VisibilityThreshold
|
||||
)
|
||||
)
|
||||
|
||||
// - Take the list of servers and filter them by the ones that are in the ordering.
|
||||
// - Sort the servers that are in the ordering using the ordering.
|
||||
// - Add the servers that aren't in the ordering to the end of the list.
|
||||
|
|
|
|||
|
|
@ -114,21 +114,8 @@ sealed class ChatRouterDestination {
|
|||
data class ServersChannels(val serverID: String) : ChatRouterDestination()
|
||||
data class NoCurrentChannel(val serverId: String?) : ChatRouterDestination()
|
||||
|
||||
fun asSerialisedString(): String? {
|
||||
return when (this) {
|
||||
is Settings -> "overview"
|
||||
is Friends -> "friends"
|
||||
is Discover -> "discover"
|
||||
is Channel -> null
|
||||
is ServersChannels -> "channel/$serverID/servers"
|
||||
is NoCurrentChannel -> "no_current_channel/$serverId"
|
||||
ChatRouterDestination.Home -> "home"
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val default = Settings
|
||||
val defaultForDMList = Settings
|
||||
|
||||
fun fromString(destination: String): ChatRouterDestination {
|
||||
return when {
|
||||
|
|
@ -245,13 +232,7 @@ class ChatRouterViewModel @Inject constructor(
|
|||
|
||||
fun navigateToServer(serverId: String) {
|
||||
viewModelScope.launch {
|
||||
val savedLastChannel = kvStorage.get("lastChannel/$serverId")
|
||||
val channelId =
|
||||
savedLastChannel ?: RevoltAPI.serverCache[serverId]?.channels?.firstOrNull()
|
||||
val channelExists = RevoltAPI.channelCache.containsKey(channelId)
|
||||
|
||||
setSaveDestination(ChatRouterDestination.ServersChannels(serverId))
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue