From 57676bf4bb997e36659cc733d6353e42393c66a3 Mon Sep 17 00:00:00 2001 From: Zane Schepke Date: Sat, 30 Nov 2024 13:18:47 -0500 Subject: [PATCH] fix: copy tunnel bug --- .../wireguardautotunnel/ui/screens/main/MainScreen.kt | 7 ++----- .../wireguardautotunnel/ui/screens/main/MainViewModel.kt | 8 +------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainScreen.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainScreen.kt index bf6b126..e12e6f2 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainScreen.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainScreen.kt @@ -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, diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainViewModel.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainViewModel.kt index 9c821c2..f000325 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainViewModel.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/main/MainViewModel.kt @@ -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) ) }