Make outlet optional for safety
This commit is contained in:
parent
6e46b4c94a
commit
b6d419beed
|
@ -30,7 +30,7 @@ import Passepartout_Core
|
||||||
private let log = SwiftyBeaver.self
|
private let log = SwiftyBeaver.self
|
||||||
|
|
||||||
class DebugLogViewController: UIViewController {
|
class DebugLogViewController: UIViewController {
|
||||||
@IBOutlet private weak var textLog: UITextView!
|
@IBOutlet private weak var textLog: UITextView?
|
||||||
|
|
||||||
private let vpn = VPN.shared
|
private let vpn = VPN.shared
|
||||||
|
|
||||||
|
@ -44,11 +44,13 @@ class DebugLogViewController: UIViewController {
|
||||||
applyDetailTitle(Theme.current)
|
applyDetailTitle(Theme.current)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: UIViewController
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
title = L10n.Service.Cells.DebugLog.caption
|
title = L10n.Service.Cells.DebugLog.caption
|
||||||
textLog.contentInsetAdjustmentBehavior = .never
|
textLog?.contentInsetAdjustmentBehavior = .never
|
||||||
|
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(vpnDidPrepare), name: .VPNDidPrepare, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(vpnDidPrepare), name: .VPNDidPrepare, object: nil)
|
||||||
if vpn.isPrepared {
|
if vpn.isPrepared {
|
||||||
|
@ -56,8 +58,10 @@ class DebugLogViewController: UIViewController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: Actions
|
||||||
|
|
||||||
@IBAction private func share(_ sender: Any?) {
|
@IBAction private func share(_ sender: Any?) {
|
||||||
guard let raw = textLog.text, !raw.isEmpty else {
|
guard let raw = textLog?.text, !raw.isEmpty else {
|
||||||
let alert = Macros.alert(title, L10n.DebugLog.Alerts.EmptyLog.message)
|
let alert = Macros.alert(title, L10n.DebugLog.Alerts.EmptyLog.message)
|
||||||
alert.addCancelAction(L10n.Global.ok)
|
alert.addCancelAction(L10n.Global.ok)
|
||||||
present(alert, animated: true, completion: nil)
|
present(alert, animated: true, completion: nil)
|
||||||
|
@ -82,19 +86,19 @@ class DebugLogViewController: UIViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction private func previousSession() {
|
@IBAction private func previousSession() {
|
||||||
textLog.findPrevious(string: GroupConstants.VPN.sessionMarker)
|
textLog?.findPrevious(string: GroupConstants.VPN.sessionMarker)
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction private func nextSession() {
|
@IBAction private func nextSession() {
|
||||||
textLog.findNext(string: GroupConstants.VPN.sessionMarker)
|
textLog?.findNext(string: GroupConstants.VPN.sessionMarker)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func startRefreshingLog() {
|
private func startRefreshingLog() {
|
||||||
vpn.requestDebugLog(fallback: AppConstants.Log.debugSnapshot) {
|
vpn.requestDebugLog(fallback: AppConstants.Log.debugSnapshot) {
|
||||||
self.textLog.text = $0
|
self.textLog?.text = $0
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.textLog.scrollToEnd()
|
self.textLog?.scrollToEnd()
|
||||||
self.refreshLogInBackground()
|
self.refreshLogInBackground()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,7 +118,7 @@ class DebugLogViewController: UIViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
vpn.requestDebugLog(fallback: AppConstants.Log.debugSnapshot) {
|
vpn.requestDebugLog(fallback: AppConstants.Log.debugSnapshot) {
|
||||||
self.textLog.text = $0
|
self.textLog?.text = $0
|
||||||
updateBlock()
|
updateBlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue