summaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2018-01-01 02:15:34 -0600
committerSamuel Holland <samuel@sholland.org>2018-01-06 04:09:30 -0600
commit58eedfd6d90a11aa803277b2bfd9eef6dd2258be (patch)
treef2d97bab075766e3da4e976b23038be7eaf7ce0d /app
parent609194fae2332e6f2ccd7a4464bfa492ad661a6f (diff)
TunnelManager: Clear primary tunnel when it's removed
Signed-off-by: Samuel Holland <samuel@sholland.org>
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/com/wireguard/android/model/TunnelManager.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/src/main/java/com/wireguard/android/model/TunnelManager.java b/app/src/main/java/com/wireguard/android/model/TunnelManager.java
index 5122f9bf..b6f6819d 100644
--- a/app/src/main/java/com/wireguard/android/model/TunnelManager.java
+++ b/app/src/main/java/com/wireguard/android/model/TunnelManager.java
@@ -70,7 +70,11 @@ public final class TunnelManager {
Log.v(TAG, "Requested delete tunnel " + tunnel.getName() + " state=" + tunnel.getState());
return backend.setState(tunnel, State.DOWN)
.thenCompose(x -> configStore.delete(tunnel.getName()))
- .thenAccept(x -> tunnels.remove(tunnel.getName()));
+ .thenAccept(x -> {
+ tunnels.remove(tunnel.getName());
+ if (tunnel.getName().equals(preferences.getString(KEY_PRIMARY_TUNNEL, null)))
+ preferences.edit().remove(KEY_PRIMARY_TUNNEL).apply();
+ });
}
public TunnelCollection getTunnels() {