From 662d0692dfe02a0d8e361d1ae9d836d8dfaf2b67 Mon Sep 17 00:00:00 2001 From: Reece Browne Date: Wed, 3 Sep 2025 23:56:14 +0100 Subject: [PATCH] additional clean up --- frontend/src/types/fileContext.ts | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/frontend/src/types/fileContext.ts b/frontend/src/types/fileContext.ts index 2d5c9e034..76b197e3b 100644 --- a/frontend/src/types/fileContext.ts +++ b/frontend/src/types/fileContext.ts @@ -102,26 +102,13 @@ export function createStirlingFile(file: File, id?: FileId): StirlingFile { const fileId = id || createFileId(); const quickKey = createQuickKey(file); - // File properties are not enumerable, so we need to copy them explicitly - // This avoids prototype chain issues while preserving all File functionality - const stirlingFile = { - // Explicitly copy File properties (they're not enumerable) - name: file.name, - size: file.size, - type: file.type, - lastModified: file.lastModified, - webkitRelativePath: file.webkitRelativePath, - - // Add our custom properties - fileId: fileId, - quickKey: quickKey, - - // Preserve File prototype methods by binding them to the original file - arrayBuffer: file.arrayBuffer.bind(file), - slice: file.slice.bind(file), - stream: file.stream.bind(file), - text: file.text.bind(file) - } as StirlingFile; + // Create a new object that inherits from the File instance + // This preserves all File methods and properties while avoiding binding issues + const stirlingFile = Object.assign( + Object.create(Object.getPrototypeOf(file)), // Proper prototype chain + file, // Copy all properties (enumerable and non-enumerable) + { fileId, quickKey } // Add our custom properties + ) as StirlingFile; return stirlingFile; }