File tree Expand file tree Collapse file tree 1 file changed +11
-15
lines changed
src/app/shared/ui/file-change Expand file tree Collapse file tree 1 file changed +11
-15
lines changed Original file line number Diff line number Diff line change @@ -14,9 +14,9 @@ export class FileChangeComponent implements OnInit {
14
14
this . initFileInput ( ) ;
15
15
16
16
if ( "launchQueue" in window ) {
17
- console . log ( `"launchQueue" in window` ) ;
18
-
19
17
( window as any ) . launchQueue . setConsumer ( async ( launchParams : any ) => {
18
+ console . log ( launchParams ) ;
19
+
20
20
const file : File = launchParams . files [ 0 ] ;
21
21
this . fileHandler ( file )
22
22
} ) ;
@@ -51,20 +51,16 @@ export class FileChangeComponent implements OnInit {
51
51
}
52
52
53
53
getRouteType ( file : File ) : string | undefined {
54
- const fileType = file . type
55
-
56
- if ( fileType ) {
57
- if ( fileType . search ( / z i p | c b z / ) >= 0 ) return "zip"
58
- else if ( fileType . includes ( 'pdf' ) ) return "pdf"
59
- } else {
60
- const fileName = file . name
61
- const extension = fileName . substring ( fileName . lastIndexOf ( '.' ) ) . toLowerCase ( ) ;
62
-
63
- return [ 'cbz' , 'zip' , 'pdf' ] . includes ( extension ) ? extension : undefined
64
- }
65
-
66
- return ;
54
+ const fileType = file . type || file . name . split ( '.' ) . pop ( ) ?. toLowerCase ( ) ;
55
+
56
+ if ( ! fileType ) return undefined ;
57
+
58
+ if ( fileType . includes ( 'pdf' ) ) return 'pdf' ;
59
+ if ( / z i p | c b z / . test ( fileType ) ) return 'zip' ;
60
+
61
+ return undefined ;
67
62
}
63
+
68
64
input = document . createElement ( 'input' )
69
65
70
66
initFileInput ( ) {
You can’t perform that action at this time.
0 commit comments