This repository has been archived on 2024-03-04. You can view files and clone it, but cannot push or open issues or pull requests.
maatma-videos/src/routes/__layout.svelte

62 lines
1.4 KiB
Svelte

<script context="module">
import { videos } from '../stores/videos.js';
let stop_refresh = false;
let refresh_interval_videos = null;
async function refresh_videos(cb=null, interval=null) {
if (refresh_interval_videos)
clearInterval(refresh_interval_videos);
if (interval === null) {
interval = Math.floor(Math.random() * 124800) + 600000;
}
if (stop_refresh) {
return;
}
refresh_interval_videos = setInterval(refresh_videos, interval);
await videos.update(await fetch('videos.json', {headers: {'Accept': 'application/json'}}), cb);
}
export async function load({ stuff }) {
refresh_videos();
return {
stuff: {
...stuff,
refresh_videos,
},
};
}
</script>
<script>
import "bootstrap-icons/font/bootstrap-icons.css";
import {
Container,
Styles,
} from 'sveltestrap';
import Header from '../components/Header.svelte';
export let loading = null;
</script>
<svelte:head>
<title>Maatma Videos</title>
</svelte:head>
<Styles />
<Header />
<Container fluid class="flex-fill d-flex flex-column justify-content-center pb-4 pb-lg-2">
{#if $videos.loading}
<Container class="border border-2 border-info text-center py-3 display-6 mb-5">
Chargement de la liste des vidéos&hellip;
</Container>
{:else}
<slot></slot>
{/if}
</Container>