|
@@ -50,9 +50,12 @@ class WebxdcViewController: WebViewViewController {
|
|
|
|
|
|
setUpdateListener: (cb) => (update_listener = cb),
|
|
setUpdateListener: (cb) => (update_listener = cb),
|
|
|
|
|
|
- async getAllUpdates: () => {
|
|
|
|
|
|
+ getAllUpdates: () => {
|
|
// FIXME: we need to add an callback here, comp. https://programming.vip/docs/the-perfect-solution-for-wkwebview-to-interact-with-js.html
|
|
// FIXME: we need to add an callback here, comp. https://programming.vip/docs/the-perfect-solution-for-wkwebview-to-interact-with-js.html
|
|
- return JSON.parse(webkit.messageHandlers.getStatusUpdatesHandler.postMessage(0));
|
|
|
|
|
|
+ webkit.messageHandlers.getStatusUpdatesHandler.postMessage("0")
|
|
|
|
+ // call to webkit.messageHandlers.getStatusUpdatesHandler.postMessage("0") doesn't return anything currently but showcases
|
|
|
|
+ // the communication js -> swift is working
|
|
|
|
+ return Promise.resolve([]);
|
|
},
|
|
},
|
|
|
|
|
|
sendUpdate: (payload, descr) => {
|
|
sendUpdate: (payload, descr) => {
|
|
@@ -172,11 +175,13 @@ extension WebxdcViewController: WKScriptMessageHandler {
|
|
switch handler {
|
|
switch handler {
|
|
case .getStatusUpdates:
|
|
case .getStatusUpdates:
|
|
logger.debug("getStatusUpdates called")
|
|
logger.debug("getStatusUpdates called")
|
|
- guard let param = message.body as? Int else {
|
|
|
|
|
|
+ guard let param = message.body as? String,
|
|
|
|
+ let statusId = Int(param) else {
|
|
logger.error("could not convert param \(message.body) to int")
|
|
logger.error("could not convert param \(message.body) to int")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- // let statusUpdates = dcContext.getWebxdcStatusUpdates(msgId: messageId, statusUpdateId: param)
|
|
|
|
|
|
+ let statusUpdates = dcContext.getWebxdcStatusUpdates(msgId: messageId, statusUpdateId: statusId)
|
|
|
|
+ logger.debug("status updates for message \(messageId) and statusId: \(statusId): \(statusUpdates)")
|
|
// TODO: return
|
|
// TODO: return
|
|
case .sendStatusUpdate:
|
|
case .sendStatusUpdate:
|
|
logger.debug("sendStatusUpdate called")
|
|
logger.debug("sendStatusUpdate called")
|