Skip to content

Commit

Permalink
More robust way of watching
Browse files Browse the repository at this point in the history
  • Loading branch information
Dianliang233 committed Oct 14, 2024
1 parent 7a71520 commit 3571b5d
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/tools/chunkbase/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,6 @@ const edition = ref<'java' | 'bedrock'>('java')
const iframe = useTemplateRef('iframe')
watch([edition], () => {
if (iframe.value === null) return
const src = iframe.value.src
iframe.value.src = ''
setTimeout(() => {
if (iframe.value === null) return
iframe.value.src = src
})
})
const chunkbaseUrl = computed(() => {
const normalizedParams: Record<string, string> = {}
for (const [key, value] of Object.entries(params.value)) {
Expand Down Expand Up @@ -196,6 +186,15 @@ const chunkbaseUrl = computed(() => {
'https://www.chunkbase.com/seed-map-embed',
).toString()
})
watch([chunkbaseUrl], () => {
if (iframe.value === null) return
iframe.value.src = ''
setTimeout(() => {
if (iframe.value === null) return
iframe.value.src = chunkbaseUrl.value
})
})
</script>

<template>
Expand Down

0 comments on commit 3571b5d

Please sign in to comment.