fix: copy tunnel bug

This commit is contained in:
Zane Schepke 2024-11-30 13:18:47 -05:00
parent 921e33cb70
commit 57676bf4bb
2 changed files with 3 additions and 12 deletions

View File

@ -248,13 +248,10 @@ fun MainScreen(viewModel: MainViewModel = hiltViewModel(), uiState: AppUiState)
uiState.tunnels,
key = { tunnel -> tunnel.id },
) { tunnel ->
val isActive = uiState.tunnels.any {
it.id == uiState.vpnState.tunnelConfig?.id &&
uiState.vpnState.status.isUp()
}
val expanded = uiState.generalState.isTunnelStatsExpanded
TunnelRowItem(
isActive,
tunnel.id == uiState.vpnState.tunnelConfig?.id &&
uiState.vpnState.status.isUp(),
expanded,
selectedTunnel?.id == tunnel.id,
tunnel,

View File

@ -252,13 +252,7 @@ constructor(
fun onCopyTunnel(tunnel: TunnelConfig) = viewModelScope.launch {
saveTunnel(
tunnel.copy(
id = 0,
isPrimaryTunnel = false,
isMobileDataTunnel = false,
isActive = false,
name = makeTunnelNameUnique(tunnel.name),
),
TunnelConfig(name = makeTunnelNameUnique(tunnel.name), wgQuick = tunnel.wgQuick, amQuick = tunnel.amQuick)
)
}