mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 03:50:08 +02:00
👌 Reinstate UI busy for secure, add fake delay
This commit is contained in:
@ -68,43 +68,45 @@ extension DomainListVC {
|
||||
|
||||
@objc func toggleSecure() {
|
||||
if selected is ValetSite {
|
||||
Task { await toggleSecureForSite() }
|
||||
} else {
|
||||
Task { await toggleSecureForProxy() }
|
||||
Task { await toggleSecure(site: selected as! ValetSite) }
|
||||
}
|
||||
|
||||
if selected is ValetProxy {
|
||||
Task { await toggleSecure(proxy: selected as! ValetProxy) }
|
||||
}
|
||||
}
|
||||
|
||||
func toggleSecureForProxy() async {
|
||||
guard let proxy = selectedProxy else { return }
|
||||
|
||||
do {
|
||||
// Recreate proxy as secure or unsecured proxy
|
||||
try await proxy.toggleSecure()
|
||||
// Send a notification about the new status (if applicable)
|
||||
self.notifyAboutModifiedSecureStatus(domain: proxy.domain, secured: proxy.secured)
|
||||
// Reload the UI (do this last so we don't invalidate the proxy)
|
||||
self.reloadSelectedRow()
|
||||
} catch {
|
||||
// Notify the user about a failed command
|
||||
let error = error as! ValetInteractionError
|
||||
self.notifyAboutFailedSecureStatus(command: error.command)
|
||||
func toggleSecure(proxy: ValetProxy) async {
|
||||
waitAndExecute {
|
||||
do {
|
||||
// Recreate proxy as secure or unsecured proxy
|
||||
try await proxy.toggleSecure()
|
||||
// Send a notification about the new status (if applicable)
|
||||
self.notifyAboutModifiedSecureStatus(domain: proxy.domain, secured: proxy.secured)
|
||||
// Reload the UI (do this last so we don't invalidate the proxy)
|
||||
self.reloadSelectedRow()
|
||||
} catch {
|
||||
// Notify the user about a failed command
|
||||
let error = error as! ValetInteractionError
|
||||
self.notifyAboutFailedSecureStatus(command: error.command)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func toggleSecureForSite() async {
|
||||
guard let site = selectedSite else { return }
|
||||
|
||||
do {
|
||||
// Instruct Valet to secure or unsecure a site
|
||||
try await site.toggleSecure()
|
||||
// Send a notification about the new status (if applicable)
|
||||
self.notifyAboutModifiedSecureStatus(domain: site.name, secured: site.secured)
|
||||
// Reload the UI (do this last so we don't invalidate the proxy)
|
||||
self.reloadSelectedRow()
|
||||
} catch {
|
||||
// Notify the user about a failed command
|
||||
let error = error as! ValetInteractionError
|
||||
self.notifyAboutFailedSecureStatus(command: error.command)
|
||||
func toggleSecure(site: ValetSite) async {
|
||||
waitAndExecute {
|
||||
do {
|
||||
// Instruct Valet to secure or unsecure a site
|
||||
try await site.toggleSecure()
|
||||
// Send a notification about the new status (if applicable)
|
||||
self.notifyAboutModifiedSecureStatus(domain: site.name, secured: site.secured)
|
||||
// Reload the UI (do this last so we don't invalidate the site)
|
||||
self.reloadSelectedRow()
|
||||
} catch {
|
||||
// Notify the user about a failed command
|
||||
let error = error as! ValetInteractionError
|
||||
self.notifyAboutFailedSecureStatus(command: error.command)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,21 +83,27 @@ class ValetInteractor {
|
||||
}
|
||||
|
||||
class FakeValetInteractor: ValetInteractor {
|
||||
var delayTime: TimeInterval = 1.0
|
||||
|
||||
override func toggleSecure(proxy: ValetProxy) async throws {
|
||||
await delay(seconds: delayTime)
|
||||
proxy.secured = !proxy.secured
|
||||
}
|
||||
|
||||
override func toggleSecure(site: ValetSite) async throws {
|
||||
await delay(seconds: delayTime)
|
||||
site.secured = !site.secured
|
||||
}
|
||||
|
||||
override func unlink(site: ValetSite) async throws {
|
||||
await delay(seconds: delayTime)
|
||||
if let scanner = ValetScanners.siteScanner as? FakeSiteScanner {
|
||||
scanner.fakes.removeAll { $0 === site }
|
||||
}
|
||||
}
|
||||
|
||||
override func remove(proxy: ValetProxy) async throws {
|
||||
await delay(seconds: delayTime)
|
||||
#warning("A fake proxy scanner needs to be added")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user