diff --git a/src/gui/src/helpers/launch_app.js b/src/gui/src/helpers/launch_app.js index 192bc63901..693b198963 100644 --- a/src/gui/src/helpers/launch_app.js +++ b/src/gui/src/helpers/launch_app.js @@ -208,21 +208,14 @@ const launch_app = async (options)=>{ } if(file_signature){ + // Only pass the file UUID to the app, and let onLaunchedWithItems + // fetch the complete file information via puter.js iframe_url.searchParams.append('puter.item.uid', file_signature.uid); - iframe_url.searchParams.append('puter.item.path', privacy_aware_path(options.file_path) || file_signature.path); - iframe_url.searchParams.append('puter.item.name', file_signature.fsentry_name); - iframe_url.searchParams.append('puter.item.read_url', file_signature.read_url); - iframe_url.searchParams.append('puter.item.write_url', file_signature.write_url); - iframe_url.searchParams.append('puter.item.metadata_url', file_signature.metadata_url); - iframe_url.searchParams.append('puter.item.size', file_signature.fsentry_size); - iframe_url.searchParams.append('puter.item.accessed', file_signature.fsentry_accessed); - iframe_url.searchParams.append('puter.item.modified', file_signature.fsentry_modified); - iframe_url.searchParams.append('puter.item.created', file_signature.fsentry_created); } - else if(options.readURL){ - iframe_url.searchParams.append('puter.item.name', options.filename); - iframe_url.searchParams.append('puter.item.path', privacy_aware_path(options.file_path)); - iframe_url.searchParams.append('puter.item.read_url', options.readURL); + else if(options.readURL && options.file_uid){ + // Only pass the file UUID to the app, and let onLaunchedWithItems + // fetch the complete file information via puter.js + iframe_url.searchParams.append('puter.item.uid', options.file_uid); } // In godmode, we add the super token to the iframe URL diff --git a/src/puter-js/src/modules/UI.js b/src/puter-js/src/modules/UI.js index 5e25f40d2d..4df6618f05 100644 --- a/src/puter-js/src/modules/UI.js +++ b/src/puter-js/src/modules/UI.js @@ -605,24 +605,22 @@ class UI extends EventListener { // the URL parameters will be checked every time the callback is set which can cause problems if the callback is set multiple times. if(!this.#onLaunchedWithItems){ let URLParams = new URLSearchParams(window.location.search); - if(URLParams.has('puter.item.name') && URLParams.has('puter.item.uid') && URLParams.has('puter.item.read_url')){ - let fpath = URLParams.get('puter.item.path'); - - if(!fpath.startsWith('~/') && !fpath.startsWith('/')) - fpath = '~/' + fpath; - - callback([new FSItem({ - name: URLParams.get('puter.item.name'), - path: fpath, - uid: URLParams.get('puter.item.uid'), - readURL: URLParams.get('puter.item.read_url'), - writeURL: URLParams.get('puter.item.write_url'), - metadataURL: URLParams.get('puter.item.metadata_url'), - size: URLParams.get('puter.item.size'), - accessed: URLParams.get('puter.item.accessed'), - modified: URLParams.get('puter.item.modified'), - created: URLParams.get('puter.item.created'), - })]); + if(URLParams.has('puter.item.uid')){ + const fileUID = URLParams.get('puter.item.uid'); + + // Fetch the complete file information using the UID + puter.fs.stat({ uid: fileUID }) + .then(fileInfo => { + // Create an FSItem with the complete information + callback([new FSItem(fileInfo)]); + }) + .catch(error => { + console.error('Error fetching file information:', error); + // If there's an error, still call the callback with the minimal information + callback([new FSItem({ + uid: fileUID + })]); + }); } }