Skip to content

Commit 687cefb

Browse files
committed
Various fixes
1 parent 02f2607 commit 687cefb

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

‎submodules/WebUI/Sources/WebAppController.swift‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2308,8 +2308,19 @@ public final class WebAppController: ViewController, AttachmentContainable {
23082308
guard let self else {
23092309
return
23102310
}
2311-
let paramsString = "{req_id: \"\(requestId)\", result: \(result)}"
2312-
self.webView?.sendEvent(name: "custom_method_invoked", data: paramsString)
2311+
var payload: [String: Any] = ["req_id": requestId]
2312+
if let data = result.data(using: .utf8), let json = try? JSONSerialization.jsonObject(with: data, options: [.fragmentsAllowed]) {
2313+
payload["result"] = json
2314+
} else {
2315+
payload["result"] = [:]
2316+
}
2317+
guard let jsonData = try? JSONSerialization.data(withJSONObject: payload) else {
2318+
return
2319+
}
2320+
guard let jsonDataString = String(data: jsonData, encoding: .utf8) else {
2321+
return
2322+
}
2323+
self.webView?.sendEvent(name: "custom_method_invoked", data: jsonDataString)
23132324
})
23142325
}
23152326

0 commit comments

Comments
 (0)