diff --git a/src/main/java/org/thoughtcrime/securesms/WebxdcActivity.java b/src/main/java/org/thoughtcrime/securesms/WebxdcActivity.java index 4012378d7..b126d0c10 100644 --- a/src/main/java/org/thoughtcrime/securesms/WebxdcActivity.java +++ b/src/main/java/org/thoughtcrime/securesms/WebxdcActivity.java @@ -365,8 +365,11 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE callJavaScriptFunction("__webxdcUpdate()"); } else if ((eventId == DcContext.DC_EVENT_WEBXDC_REALTIME_DATA && event.getData1Int() == dcAppMsg.getId())) { Log.i(TAG, "handling realtime data event"); - String base64 = Base64.encodeToString(event.getData2Blob(), Base64.NO_WRAP | Base64.NO_PADDING); - callJavaScriptFunction("__webxdcRealtimeData(\"" + base64 + "\")"); + StringBuilder data = new StringBuilder(); + for (byte b : event.getData2Blob()) { + data.append(((int) b) + ","); + } + callJavaScriptFunction("__webxdcRealtimeData([" + data + "])"); } else if ((eventId == DcContext.DC_EVENT_MSGS_CHANGED && event.getData2Int() == dcAppMsg.getId())) { this.dcAppMsg = this.dcContext.getMsg(event.getData2Int()); // msg changed, reload data from db Util.runOnAnyBackgroundThread(() -> { diff --git a/src/main/res/raw/webxdc.js b/src/main/res/raw/webxdc.js index bc34960e9..9d23bdbf5 100644 --- a/src/main/res/raw/webxdc.js +++ b/src/main/res/raw/webxdc.js @@ -16,10 +16,9 @@ window.webxdc = (() => { } }; - window.__webxdcRealtimeData = (base64Data) => { + window.__webxdcRealtimeData = (intArray) => { if (realtimeChannel) { - const data = Uint8Array.from(atob(base64Data), (m) => m.codePointAt(0)); - realtimeChannel.__receive(data); + realtimeChannel.__receive(Uint8Array.from(intArray)); } };