Skip to content

Commit

Permalink
code review #1
Browse files Browse the repository at this point in the history
  • Loading branch information
jyyi1 committed Nov 4, 2024
1 parent 77b3766 commit f374817
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions client/src/cordova/plugin/apple/src/OutlinePlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -291,46 +291,46 @@ class OutlinePlugin: CDVPlugin {
return; // Do not report transient or invalid states.
}
let result = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: ["id": tunnelId, "status": Int32(tunnelStatus)])
send(pluginResult: result, callbackId: callbackId, keepCallback: true)
self.send(pluginResult: result, callbackId: callbackId, keepCallback: true)
}

// MARK: - Callback helpers

private func sendSuccess(callbackId: String, keepCallback: Bool = false) {
let result = CDVPluginResult(status: CDVCommandStatus_OK)
send(pluginResult: result, callbackId: callbackId, keepCallback: keepCallback)
let result = CDVPluginResult(status: CDVCommandStatus_OK)
self.send(pluginResult: result, callbackId: callbackId, keepCallback: keepCallback)
}

private func sendSuccess(_ operationResult: String, callbackId: String, keepCallback: Bool = false) {
let result = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: operationResult)
send(pluginResult: result, callbackId: callbackId, keepCallback: keepCallback)
self.send(pluginResult: result, callbackId: callbackId, keepCallback: keepCallback)
}

private func sendSuccess(_ operationResult: Bool, callbackId: String, keepCallback: Bool = false) {
let result = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: operationResult)
send(pluginResult: result, callbackId: callbackId, keepCallback: keepCallback)
let result = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: operationResult)
self.send(pluginResult: result, callbackId: callbackId, keepCallback: keepCallback)
}

private func sendError(_ message: String, callbackId: String, keepCallback: Bool = false) {
DDLogWarn("plugin result error: \(message)")
let result = CDVPluginResult(status: CDVCommandStatus_ERROR, messageAs: message)
send(pluginResult: result, callbackId: callbackId, keepCallback: keepCallback)
self.send(pluginResult: result, callbackId: callbackId, keepCallback: keepCallback)
}

private func send(pluginResult: CDVPluginResult?, callbackId: String, keepCallback: Bool) {
guard let result = pluginResult else {
return DDLogWarn("Missing plugin result");
}
result.setKeepCallbackAs(keepCallback)
self.commandDelegate?.send(result, callbackId: callbackId)
guard let result = pluginResult else {
return DDLogWarn("Missing plugin result");
}
result.setKeepCallbackAs(keepCallback)
self.commandDelegate?.send(result, callbackId: callbackId)
}

private func removeCallback(withId callbackId: String) {
guard let result = CDVPluginResult(status: CDVCommandStatus_NO_RESULT) else {
return DDLogWarn("Missing plugin result for callback \(callbackId)");
}
result.setKeepCallbackAs(false)
self.commandDelegate?.send(result, callbackId: callbackId)
guard let result = CDVPluginResult(status: CDVCommandStatus_NO_RESULT) else {
return DDLogWarn("Missing plugin result for callback \(callbackId)");
}
result.setKeepCallbackAs(false)
self.commandDelegate?.send(result, callbackId: callbackId)
}

// Migrates local storage files from UIWebView to WKWebView.
Expand Down

0 comments on commit f374817

Please sign in to comment.