fix: Bug - Local files should be remembered by client

This commit is contained in:
2026-06-11 01:54:00 +02:00
parent 5bf4f698df
commit 494a05e606
19 changed files with 1611 additions and 143 deletions

View File

@@ -1,6 +1,9 @@
/** Chunk size used when rebuilding attachment blobs from disk without blocking the UI thread. */
export const ATTACHMENT_BLOB_READ_CHUNK_SIZE_BYTES = 256 * 1024;
/** Number of bytes encoded per chunk to keep base64 encoding off the call stack. */
const BASE64_ENCODE_CHUNK_SIZE = 0x8000;
/** Decode a base64 payload into bytes for Blob construction. */
export function decodeBase64ToUint8Array(base64: string): Uint8Array {
const binary = atob(base64);
@@ -13,6 +16,19 @@ export function decodeBase64ToUint8Array(base64: string): Uint8Array {
return bytes;
}
/** Encode bytes into a base64 payload, chunked so large buffers cannot overflow the call stack. */
export function encodeUint8ArrayToBase64(bytes: Uint8Array): string {
let binary = '';
for (let offset = 0; offset < bytes.length; offset += BASE64_ENCODE_CHUNK_SIZE) {
const chunk = bytes.subarray(offset, offset + BASE64_ENCODE_CHUNK_SIZE);
binary += String.fromCharCode(...chunk);
}
return btoa(binary);
}
/** Yield control back to the browser so long attachment hydration cannot freeze Electron. */
export function yieldToAttachmentHydrationLoop(): Promise<void> {
return new Promise((resolve) => {