Skip to content

Build your personal knowledge base with Trilium Notes

chore(mobile): address requested changes

Elian Doran8e2c50059ae2
diff --git a/apps/client-standalone/src/lightweight/bridged_request_provider.ts b/apps/client-standalone/src/lightweight/bridged_request_provider.ts
index 4042802fb7..6980c74043 100644
--- a/apps/client-standalone/src/lightweight/bridged_request_provider.ts
+++ b/apps/client-standalone/src/lightweight/bridged_request_provider.ts
@@ -139,10 +139,7 @@ export default class BridgedRequestProvider implements RequestProvider {
// The main thread should send back a base64-encoded body for binary responses
const binary = atob(msg.body);
- const bytes = new Uint8Array(binary.length);
- for (let i = 0; i < binary.length; i++) {
- bytes[i] = binary.charCodeAt(i);
- }
+ const bytes = Uint8Array.from(binary, (c) => c.charCodeAt(0));
return bytes.buffer;
}
}
diff --git a/apps/client-standalone/src/services/capacitor_http_handler.ts b/apps/client-standalone/src/services/capacitor_http_handler.ts
index 7375184708..8ed7befd40 100644
--- a/apps/client-standalone/src/services/capacitor_http_handler.ts
+++ b/apps/client-standalone/src/services/capacitor_http_handler.ts
@@ -21,6 +21,7 @@ function getCapacitorHttp() {
url: string;
headers: Record<string, string>;
data?: string;
+ responseType?: string;
}): Promise<CapacitorHttpResponse>;
};
}
@@ -36,7 +37,8 @@ export const capacitorHttpHandler: NativeHttpHandler = async (request) => {
method: request.method,
url: request.url,
headers: request.headers,
- data: request.body
+ data: request.body,
+ responseType: request.responseType
});
// Normalize header keys to lowercase for consistent access in the worker
@@ -47,12 +49,8 @@ export const capacitorHttpHandler: NativeHttpHandler = async (request) => {
let body: string;
if (request.responseType === "arraybuffer") {
- // For binary responses, encode as base64 for postMessage transfer
- if (typeof response.data === "string") {
- body = btoa(response.data);
- } else {
- body = btoa(JSON.stringify(response.data));
- }
+ // Capacitor returns binary data as a base64 string — pass it through directly
+ body = String(response.data);
} else {
body = typeof response.data === "string"
? response.data