File tree 1 file changed +17
-6
lines changed
sites/preview/src/lib/components/tree
1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change 1
1
<script lang =" ts" >
2
- import { FileNode , FolderNode , type FileTreeNode } from " $lib/tree.svelte.js" ;
2
+ import { FileNode , FileTree , FolderNode , type FileTreeNode } from " $lib/tree.svelte.js" ;
3
3
import { composeEventHandlers , formatSize } from " $lib/utils.js" ;
4
4
import { ContextMenu } from " bits-ui" ;
5
5
import {
115
115
});
116
116
}
117
117
118
- async function handleUploadFiles({ target , files }: UploadFilesArgs ) {
118
+ function handleUploadFiles({ target , files }: UploadFilesArgs ) {
119
119
for (const child of target .children ) {
120
120
for (const file of files ) {
121
121
if (child .name === file .name ) {
125
125
}
126
126
}
127
127
128
- const didUpload = await onUploadFiles ({ target , files });
129
- if (didUpload ) {
130
- // TODO: show toast after upload is done
131
- }
128
+ const uploadPromise = Promise .resolve (onUploadFiles ({ target , files }));
129
+ const name = target instanceof FileTree ? " /" : target .name ;
130
+ toast .promise (uploadPromise , {
131
+ loading: ` Uploading ${files .length } file(s) to ${name } ` ,
132
+ success : (didUpload ) => {
133
+ if (! didUpload ) {
134
+ return " Failed to upload files" ;
135
+ }
136
+
137
+ return ` Uploaded ${files .length } file(s) to ${name } ` ;
138
+ },
139
+ error : (error ) => {
140
+ throw error ;
141
+ },
142
+ });
132
143
}
133
144
134
145
const contextMenuState = createContextMenuState ({
You can’t perform that action at this time.
0 commit comments