@@ -491,9 +491,6 @@ export async function extractAudioMetadata(file: File): Promise<AudioMetadata> {
491491 const { getFloMetadata, getFloCoverArt, getFloSyncedLyrics, getFloInfo } =
492492 await import ( "./floProcessor" ) ;
493493
494- const { getFloMetadata, getFloCoverArt, getFloSyncedLyrics, getFloInfo } =
495- await import ( "./floProcessor" ) ;
496-
497494 // Get all flo data in parallel
498495 const [ meta , cover , lyrics , info ] = await Promise . all ( [
499496 getFloMetadata ( arrayBuffer ) ,
@@ -855,28 +852,23 @@ export function useShareTarget(
855852 if ( urlParams . get ( "share-received" ) === "true" ) {
856853 try {
857854 const cache = await caches . open ( "incoming-shares" ) ;
858- const keys = await cache . keys ( ) ;
859-
860- const files : File [ ] = [ ] ;
861- for ( const key of keys ) {
862- if ( key . url . includes ( "/shared-file-" ) ) {
863- const response = await cache . match ( key ) ;
864- const blob = await response ?. blob ( ) ;
865- const fileName =
866- response ?. headers . get ( "x-file-name" ) || "unknown-file" ;
867- files . push ( new File ( [ blob ! ] , fileName , { type : blob ?. type } ) ) ;
868- }
869- }
855+ const response = await cache . match ( "/shared-file" ) ;
870856
871- if ( files . length > 0 ) {
872- hasProcessedRef . current = true ;
873- onShareReceived ( { files, type : "files" } ) ;
857+ if ( response ) {
858+ const blob = await response . blob ( ) ;
859+ // Try to recover the filename from headers or default to "shared-audio"
860+ const filename =
861+ response . headers . get ( "x-file-name" ) || "shared-audio.mp3" ;
862+ const file = new File ( [ blob ] , filename , { type : blob . type } ) ;
874863
875- // Cleanup the cache after processing
876- for ( const key of keys ) {
877- await cache . delete ( key ) ;
878- }
864+ hasProcessedRef . current = true ;
865+ onShareReceived ( {
866+ files : [ file ] ,
867+ type : "files" ,
868+ } ) ;
879869
870+ // Cleanup
871+ await cache . delete ( "/shared-file" ) ;
880872 const cleanUrl = new URL ( window . location . href ) ;
881873 cleanUrl . searchParams . delete ( "share-received" ) ;
882874 window . history . replaceState ( { } , "" , cleanUrl . toString ( ) ) ;
@@ -887,7 +879,7 @@ export function useShareTarget(
887879 }
888880 }
889881
890- // Fallback to text sharing (e.g., query parameters)
882+ // Fallback to standard Text/URL share handling
891883 const shareResult = handleShareTarget ( ) ;
892884 if ( shareResult && shareResult . type !== "none" ) {
893885 hasProcessedRef . current = true ;
0 commit comments