Commit 99666677 authored by Jose Blaya's avatar Jose Blaya
Browse files

Fix connection issues for Quick Connect and Favorite Server tiles

parent 343ed338
......@@ -171,6 +171,8 @@
DD172A9D2254C36D00071CFB /* FavoriteServersTileCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = DD172A992254C36D00071CFB /* FavoriteServersTileCollectionViewCell.xib */; };
DD172A9F2254C39300071CFB /* FavoriteServersTile.xib in Resources */ = {isa = PBXBuildFile; fileRef = DD172A9E2254C39300071CFB /* FavoriteServersTile.xib */; };
DD172AA02254C39300071CFB /* FavoriteServersTile.xib in Resources */ = {isa = PBXBuildFile; fileRef = DD172A9E2254C39300071CFB /* FavoriteServersTile.xib */; };
DD172AA322573EDC00071CFB /* ServerTile+App.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD172AA222573EDC00071CFB /* ServerTile+App.swift */; };
DD172AA422573EDC00071CFB /* ServerTile+App.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD172AA222573EDC00071CFB /* ServerTile+App.swift */; };
DD1AA4962180AD92005116D7 /* CustomDNSSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD1AA4952180AD92005116D7 /* CustomDNSSettingsViewController.swift */; };
DD1AA4972180AD92005116D7 /* CustomDNSSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD1AA4952180AD92005116D7 /* CustomDNSSettingsViewController.swift */; };
DD1C138621E60BAE004004B3 /* IPTile.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD1C138521E60BAE004004B3 /* IPTile.swift */; };
......@@ -514,6 +516,7 @@
DD172A982254C36D00071CFB /* FavoriteServersTileCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteServersTileCollectionViewCell.swift; sourceTree = "<group>"; };
DD172A992254C36D00071CFB /* FavoriteServersTileCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = FavoriteServersTileCollectionViewCell.xib; sourceTree = "<group>"; };
DD172A9E2254C39300071CFB /* FavoriteServersTile.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = FavoriteServersTile.xib; sourceTree = "<group>"; };
DD172AA222573EDC00071CFB /* ServerTile+App.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ServerTile+App.swift"; sourceTree = "<group>"; };
DD1AA4952180AD92005116D7 /* CustomDNSSettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomDNSSettingsViewController.swift; sourceTree = "<group>"; };
DD1C138521E60BAE004004B3 /* IPTile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IPTile.swift; sourceTree = "<group>"; };
DD1C138821E60C63004004B3 /* IPTile.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = IPTile.xib; sourceTree = "<group>"; };
......@@ -964,9 +967,18 @@
path = PIAWidget;
sourceTree = "<group>";
};
DD172AA122573ECA00071CFB /* Extensions */ = {
isa = PBXGroup;
children = (
DD172AA222573EDC00071CFB /* ServerTile+App.swift */,
);
path = Extensions;
sourceTree = "<group>";
};
DD1C137E21E6073A004004B3 /* Tiles */ = {
isa = PBXGroup;
children = (
DD172AA122573ECA00071CFB /* Extensions */,
DD1C13A321E6743F004004B3 /* TileFlowLayout.swift */,
DD1C138521E60BAE004004B3 /* IPTile.swift */,
DD125DC421E77046004ECCB6 /* QuickConnectTile.swift */,
......@@ -1875,6 +1887,7 @@
DD76291221ECBD8B0092DF50 /* SubscriptionTileCollectionViewCell.swift in Sources */,
0E392DA71FE3283C0002160D /* TransientState.swift in Sources */,
0E3A35361FD9EBDA000B0F99 /* AppDelegate.swift in Sources */,
DD172AA422573EDC00071CFB /* ServerTile+App.swift in Sources */,
0EA4ACAB20487B5800431F7D /* FakeSwitch.swift in Sources */,
DDC8124D2176185D00CB290C /* SwiftGen+SeguesStoryboards.swift in Sources */,
DDD271E221D6262100B6D20F /* PropertyStoring.swift in Sources */,
......@@ -1983,6 +1996,7 @@
DD76291121ECBD8B0092DF50 /* SubscriptionTileCollectionViewCell.swift in Sources */,
DD40197E221FEF650041EB30 /* NetworkManagementToolTileCollectionViewCell.swift in Sources */,
0ECF5C082017EBAD0047596C /* ThemeCode.swift in Sources */,
DD172AA322573EDC00071CFB /* ServerTile+App.swift in Sources */,
0E392DA61FE3283C0002160D /* TransientState.swift in Sources */,
0E3A35351FD9EBDA000B0F99 /* AppDelegate.swift in Sources */,
0EA4ACAA20487B5800431F7D /* FakeSwitch.swift in Sources */,
......
//
// ServerTile+App.swift
// PIA VPN
//
// Created by Jose Antonio Blaya Garcia on 05/04/2019.
// Copyright © 2019 London Trust Media. All rights reserved.
//
import Foundation
import PIALibrary
public extension Tileable {
/**
Connect to the server given as paramenter
- Parameter server: The server to connect.
*/
func connectTo(server: Server) {
let isConnected = Client.providers.vpnProvider.isVPNConnected
let currentServer = Client.preferences.displayedServer
if isConnected {
guard (server.identifier != currentServer.identifier) else {
return
}
}
Client.preferences.displayedServer = server
NotificationCenter.default.post(name: .PIAThemeDidChange,
object: self,
userInfo: nil)
if !isConnected {
Client.providers.vpnProvider.connect(nil)
}
}
}
......@@ -87,14 +87,7 @@ class FavoriteServersTile: UIView, Tileable {
@IBAction private func connectToServer(_ sender: ServerButton) {
if let server = sender.server {
let currentServer = Client.preferences.displayedServer
guard (server.identifier != currentServer.identifier) else {
return
}
Client.preferences.displayedServer = server
NotificationCenter.default.post(name: .PIAThemeDidChange,
object: self,
userInfo: nil)
self.connectTo(server: server)
}
}
......
......@@ -86,14 +86,7 @@ class QuickConnectTile: UIView, Tileable {
@IBAction private func connectToServer(_ sender: ServerButton) {
if let server = sender.server {
let currentServer = Client.preferences.displayedServer
guard (server.identifier != currentServer.identifier) else {
return
}
Client.preferences.displayedServer = server
NotificationCenter.default.post(name: .PIAThemeDidChange,
object: self,
userInfo: nil)
self.connectTo(server: server)
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment