minor on webcomponents
This commit is contained in:
@@ -1,16 +1,25 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte'
|
||||
export let baseurl = 'https://demo.gancio.org'
|
||||
export let id
|
||||
|
||||
let mounted = false
|
||||
let event
|
||||
|
||||
function update (id) {
|
||||
|
||||
fetch(`${baseurl}/api/event/${id}`)
|
||||
.then(res => res.json())
|
||||
.then(e => event = e)
|
||||
function update (id, baseurl) {
|
||||
if (mounted) {
|
||||
fetch(`${baseurl}/api/event/${id}`)
|
||||
.then(res => res.json())
|
||||
.then(e => event = e)
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
mounted = true
|
||||
update(id, baseurl)
|
||||
})
|
||||
$: update(id, baseurl)
|
||||
|
||||
function when (event) {
|
||||
return new Date(event.start_datetime*1000)
|
||||
.toLocaleDateString(undefined,
|
||||
@@ -35,8 +44,6 @@
|
||||
return 'center center'
|
||||
}
|
||||
|
||||
$: update(id)
|
||||
|
||||
</script>
|
||||
<svelte:options tag="gancio-event"/>
|
||||
{#if event}
|
||||
|
||||
Reference in New Issue
Block a user