diff --git a/src/app/shared/ui/file-change/file-change.component.ts b/src/app/shared/ui/file-change/file-change.component.ts index 40fb673..cdbf4b5 100644 --- a/src/app/shared/ui/file-change/file-change.component.ts +++ b/src/app/shared/ui/file-change/file-change.component.ts @@ -5,6 +5,11 @@ import { FILE_PATH } from '../../../app-routing.module'; import { LangService } from '../../data-access/lang.service'; import { isPlatformServer } from '@angular/common'; +type LaunchParams = { + files: FileSystemHandle[]; + targetURL: string +} + @Component({ selector: 'app-file-change', templateUrl: './file-change.component.html', @@ -29,14 +34,22 @@ export class FileChangeComponent implements OnInit { this.initFileInput(); if ("launchQueue" in window) { - (window as any).launchQueue.setConsumer(async (launchParams: FileSystemFileHandle) => { - console.log((launchParams as any).files[0]); - - const file: File = await launchParams.getFile(); - console.log("FileSystemFileHandle.getFile() ->", file) - console.log("FileSystemFileHandle", launchParams) - // const file: File = (launchParams as any).files[0] as File; - this.fileHandler(file) + (window as any).launchQueue.setConsumer(async (launchParams: LaunchParams) => { + + if (!launchParams.files?.length) return; + + for (const handle of launchParams.files) { + + if (handle.kind === "file") { + const fileHandle = handle as FileSystemFileHandle; + console.log("fileHandle", fileHandle) + const file = await fileHandle.getFile(); + console.log("File:", file.name); + + this.fileHandler(file); + return; + } + } }); } } diff --git a/src/index.html b/src/index.html index fac7f4e..320a99b 100644 --- a/src/index.html +++ b/src/index.html @@ -22,6 +22,7 @@ + -