Commit cd8b543 1 parent 5a2846a commit cd8b543 Copy full SHA for cd8b543
File tree 2 files changed +28
-5
lines changed
2 files changed +28
-5
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ import AudioPlayer from "./AudioPlayer.svelte"
29
29
30
30
31
31
onMount (async () => {
32
- await loadFile (file)
32
+ if ( ! await loadFile (file))
33
33
})
34
34
35
35
$: {
@@ -76,13 +76,24 @@ import AudioPlayer from "./AudioPlayer.svelte"
76
76
} else {
77
77
load = await window .api .loadFile (file .path , file .size )
78
78
}
79
- if (load[0 ] === OTHER || load[0 ] === NOT_FOUND ) return false
80
79
const [arr , type ] = load
80
+ if (! found (arr)) return
81
81
let blob = new Blob ( [ arr ]);
82
82
data = URL .createObjectURL ( blob );
83
- console .log (" Load " , data)
84
83
checkType (type)
85
84
}
85
+
86
+ const found = (file ) => {
87
+ switch (file) {
88
+ case OTHER :
89
+ data = OTHER
90
+ return false
91
+ case NOT_FOUND :
92
+ data = NOT_FOUND
93
+ return false
94
+ }
95
+ return true
96
+ }
86
97
87
98
const downloadFile = (file ) => {
88
99
clicked = true
Original file line number Diff line number Diff line change @@ -51,15 +51,27 @@ import AudioPlayer from "./AudioPlayer.svelte"
51
51
52
52
async function loadFile (file ) {
53
53
let [arr, type] = await window .api .loadFile (file .path , file .size )
54
- if (arr === OTHER || arr === NOT_FOUND ) return false
54
+ if (! found ( arr)) return
55
55
let blob = new Blob ( [ arr ]);
56
- console .log (" type" , type)
57
56
checkType (type)
58
57
data = URL .createObjectURL ( blob );
59
58
if (audio) data = new Audio (data);
60
59
return type
61
60
}
62
61
62
+
63
+ const found = (file ) => {
64
+ switch (file) {
65
+ case OTHER :
66
+ data = OTHER
67
+ return false
68
+ case NOT_FOUND :
69
+ data = NOT_FOUND
70
+ return false
71
+ }
72
+ return true
73
+ }
74
+
63
75
64
76
</script >
65
77
You can’t perform that action at this time.
0 commit comments