58 lines
2.1 KiB
Swift
58 lines
2.1 KiB
Swift
//
|
|
// PreferencesPresenter.swift
|
|
// PrivadoVPN
|
|
//
|
|
// Created by Murad Shabanov on 30.08.2021.
|
|
// Copyright © 2021 Privado LLC. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
final class PreferencesPresenter: PreferencesViewOutput {
|
|
|
|
|
|
static let title = NSLocalizedString("preference.identifier.preferences", comment: "")
|
|
private var windowOutput: PreferenceOutputProtocol?
|
|
private let interactor: PreferencesInteractorInput
|
|
weak var viewInput: PreferencesViewInput?
|
|
|
|
init(interactor: PreferencesInteractorInput, windowOutput: PreferenceOutputProtocol) {
|
|
|
|
self.interactor = interactor
|
|
self.windowOutput = windowOutput
|
|
|
|
interactor.customerChanged = { [weak self] customerIsExist in
|
|
if !customerIsExist {
|
|
self?.closeWindow()
|
|
}
|
|
}
|
|
}
|
|
|
|
// MARK: PreferencesViewOutput
|
|
|
|
func closeWindow() {
|
|
|
|
var proto = ""
|
|
|
|
if let savedProtocol = UserSettings.shared.vpnType {
|
|
proto = savedProtocol.description
|
|
}
|
|
|
|
let savedPrefences: [String: Any] = [
|
|
PrivadoConstants.Event.Preferences.killswitch: UserSettings.shared.killSwitchEnabled,
|
|
PrivadoConstants.Event.Preferences.autostart: UserSettings.shared.autostartEnabled,
|
|
PrivadoConstants.Event.Preferences.autoconnect: UserSettings.shared.preferredServer.isExist ? true : false,
|
|
PrivadoConstants.Event.Preferences.autoconnectvalue: UserSettings.shared.preferredServer?.description ?? "",
|
|
PrivadoConstants.Event.Preferences.proto: proto,
|
|
PrivadoConstants.Event.Preferences.dock: UserSettings.shared.isDocked
|
|
]
|
|
|
|
CometLogger.shared.event(name: PrivadoConstants.Event.Statistic.Application.settings,
|
|
attributes: [
|
|
PrivadoConstants.Event.Attributes.value: PrivadoConstants.Event.Attributes.success,
|
|
PrivadoConstants.Event.Attributes.extradata: savedPrefences
|
|
], secured: nil)
|
|
self.windowOutput?.closePreferences()
|
|
}
|
|
}
|