From e5ae011c10cb5aebec4fe3723646edfbec13ca70 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Sun, 24 Nov 2024 18:35:59 +0100 Subject: [PATCH] remove 'description' parameter from webxdc's sendUpdate() --- .../Controller/WebxdcViewController.swift | 17 +++++------------ deltachat-ios/DC/DcContext.swift | 4 ++-- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/deltachat-ios/Controller/WebxdcViewController.swift b/deltachat-ios/Controller/WebxdcViewController.swift index feadbf72c..a9397b7a3 100644 --- a/deltachat-ios/Controller/WebxdcViewController.swift +++ b/deltachat-ios/Controller/WebxdcViewController.swift @@ -144,13 +144,8 @@ class WebxdcViewController: WebViewViewController { return Promise.resolve([]); }, - sendUpdate: (payload, descr) => { - // only one parameter is allowed, we we create a new parameter object here - var parameter = { - payload: payload, - descr: descr - }; - webkit.messageHandlers.sendStatusUpdate.postMessage(parameter); + sendUpdate: (payload) => { + webkit.messageHandlers.sendStatusUpdate.postMessage(payload); }, sendToChat: async (message) => { @@ -481,15 +476,13 @@ extension WebxdcViewController: WKScriptMessageHandler { logger.info("webxdc log msg: " + msg) case .sendStatusUpdate: - guard let dict = message.body as? [String: AnyObject], - let payloadDict = dict["payload"] as? [String: AnyObject], + guard let payloadDict = message.body as? [String: AnyObject], let payloadJson = try? JSONSerialization.data(withJSONObject: payloadDict, options: []), - let payloadString = String(data: payloadJson, encoding: .utf8), - let description = dict["descr"] as? String else { + let payloadString = String(data: payloadJson, encoding: .utf8) else { logger.error("Failed to parse status update parameters \(message.body)") return } - _ = dcContext.sendWebxdcStatusUpdate(msgId: messageId, payload: payloadString, description: description) + _ = dcContext.sendWebxdcStatusUpdate(msgId: messageId, payload: payloadString) case .sendToChat: if let dict = message.body as? [String: AnyObject] { diff --git a/deltachat-ios/DC/DcContext.swift b/deltachat-ios/DC/DcContext.swift index 499f31bdd..9fd940eba 100644 --- a/deltachat-ios/DC/DcContext.swift +++ b/deltachat-ios/DC/DcContext.swift @@ -67,8 +67,8 @@ public class DcContext { dc_download_full_msg(contextPointer, Int32(id)) } - public func sendWebxdcStatusUpdate(msgId: Int, payload: String, description: String) -> Bool { - return dc_send_webxdc_status_update(contextPointer, UInt32(msgId), payload, description) == 1 + public func sendWebxdcStatusUpdate(msgId: Int, payload: String) -> Bool { + return dc_send_webxdc_status_update(contextPointer, UInt32(msgId), payload, nil) == 1 } public func getWebxdcStatusUpdates(msgId: Int, lastKnownSerial: Int) -> String {