Skip to content

Commit d595a3e

Browse files
watch props.files
1 parent 2c56121 commit d595a3e

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

app/components/FileSelector.vue

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,19 @@
2727
auto_upload: { type: Boolean, required: false, default: true },
2828
})
2929
30-
const { auto_upload, multiple, files, supported_feature } = props
30+
const { auto_upload, multiple, supported_feature } = props
3131
32-
const internal_files = toRef(() => props.files)
32+
const internal_files = ref(props.files)
3333
const accept = ref("")
3434
const loading = ref(false)
3535
36-
if (props.files.length) {
37-
internal_files.value = props.files
38-
if (props.auto_upload) {
39-
upload_files()
40-
}
41-
}
36+
watch(
37+
() => props.files,
38+
(newVal) => {
39+
internal_files.value = newVal
40+
},
41+
{ deep: true },
42+
)
4243
4344
const toggle_loading = useToggle(loading)
4445
@@ -64,5 +65,5 @@
6465
)
6566
toggle_loading()
6667
}
67-
get_allowed_files()
68+
await get_allowed_files()
6869
</script>

app/components/FileUploader.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
const label = props.multiple
5050
? "Please select file(s) to import"
5151
: "Please select a file to import"
52-
const internal_files = toRef(() => props.files)
52+
const internal_files = ref(props.files)
5353
const loading = ref(false)
5454
const files_uploaded = ref(false)
5555
@@ -96,6 +96,14 @@
9696
emit("files_uploaded", internal_files.value)
9797
}
9898
99+
watch(
100+
() => props.files,
101+
(newVal) => {
102+
internal_files.value = newVal
103+
},
104+
{ deep: true },
105+
)
106+
99107
watch(internal_files, (value) => {
100108
files_uploaded.value = false
101109
if (props.auto_upload) {

0 commit comments

Comments
 (0)