Skip to content

Commit af8850b

Browse files
committed
wip: prevent prop mutation when setting presigned url on current file in KBrowser #1465
1 parent c3ec3d3 commit af8850b

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

core/client/components/document/KBrowser.vue

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ const tools = computed(() => {
174174
175175
// Watch
176176
watch(() => [props.documents, props.default], async () => {
177-
if (_.size(props.document) > 0) {
178-
files.value = props.documents
177+
if (_.size(props.documents) > 0) {
178+
files.value = _.cloneDeep(props.documents)
179179
index.value = _.findIndex(files.value, { name: props.default })
180180
if (index.value < 0) index.value = 0
181181
await refresh()
@@ -185,9 +185,6 @@ watch(() => [props.documents, props.default], async () => {
185185
viewer.value = null
186186
index.value = -1
187187
}
188-
files.value = props.documents
189-
index.value = _.findIndex(files.value, { name: props.default })
190-
if (index.value > -1) await refresh()
191188
}, { immediate: true })
192189
193190
// Functions
@@ -206,7 +203,7 @@ async function next () {
206203
}
207204
async function refresh () {
208205
logger.debug('[KDK] Browser refreshed', files.value, index.value)
209-
file.value = files.value[index.value]
206+
file.value = { ...files.value[index.value] }
210207
file.value.url = await Storage.getPresignedUrl({
211208
key: getDocumentKey(file.value.name),
212209
expiresIn: 60

0 commit comments

Comments
 (0)