Make sure the sharing url is up-to-date before switch from editor to preview

This commit is contained in:
Simon Cambier 2023-11-25 08:37:17 +01:00
parent f72b7f2f56
commit e1b7961f45

View File

@ -5,6 +5,7 @@
import { shareUrl, selectedLang } from '../store' import { shareUrl, selectedLang } from '../store'
import ComboBox from './ComboBox.svelte' import ComboBox from './ComboBox.svelte'
import Icon from '@iconify/svelte' import Icon from '@iconify/svelte'
import { goto } from '$app/navigation'
type Language = { type Language = {
text: string text: string
@ -80,6 +81,11 @@
function closeUrlInput() { function closeUrlInput() {
isUrlInputVisible = false isUrlInputVisible = false
} }
async function goToPreview() {
await updateShareUrl()
goto($shareUrl)
}
</script> </script>
<div class={cssClass}> <div class={cssClass}>
@ -116,9 +122,9 @@
</button> </button>
<!-- Switch to readonly view --> <!-- Switch to readonly view -->
<a class="button" href={$shareUrl}> <button class="button" on:click={goToPreview}>
<Icon class="text-xl" icon="fluent:eye-12-regular" /> <Icon class="text-xl" icon="fluent:eye-12-regular" />
</a> </button>
</div> </div>
{/if} {/if}
</div> </div>