Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

[IP-402] Reconnects right after tapping on disconnect

  • Loading branch information
mahmoud-adam85 committed Apr 4, 2019
1 parent ae890ea commit 35ccdf0ba1930770dd2806365c256ccc0075f75a
Showing with 9 additions and 2 deletions.
  1. +9 −2 Cliqz/HomePanel/VPN/VPNViewController.swift
@@ -572,12 +572,19 @@ class VPNViewController: UIViewController {
location: VPNEndPointManager.shared.selectedCountry.id,
connectionTime: getConnectionTime())
} else {
shouldVPNReconnect = true
shouldVPNReconnect = isFirstConnection()
VPN.connect2VPN()
LegacyTelemetryHelper.logVPN(action: "click", target: "toggle", state: "on")
}
}


private func isFirstConnection() -> Bool {
let alreadyConnectedBeforeKey = "VPN.Connection.first"
let alreadyConnectedBefore = UserDefaults.standard.bool(forKey: alreadyConnectedBeforeKey)
UserDefaults.standard.set(true, forKey: alreadyConnectedBeforeKey)
return !alreadyConnectedBefore
}

private func getConnectionTime() -> Int? {
guard let connectDate = VPN.shared.connectDate else { return nil }
return Int(Date().timeIntervalSince(connectDate))

0 comments on commit 35ccdf0

Please sign in to comment.