2020-11-13 16:42:32 +01:00
|
|
|
<script>
|
2021-09-01 12:41:48 +02:00
|
|
|
import { screenStore, routeStore } from "stores"
|
2020-11-13 16:42:32 +01:00
|
|
|
import Component from "./Component.svelte"
|
2021-09-01 12:41:48 +02:00
|
|
|
import Provider from "./context/Provider.svelte"
|
2021-05-20 15:47:17 +02:00
|
|
|
import { onMount } from "svelte"
|
2020-11-13 16:42:32 +01:00
|
|
|
|
2020-11-18 20:18:18 +01:00
|
|
|
// Keep route params up to date
|
2020-11-30 16:05:36 +01:00
|
|
|
export let params = {}
|
2020-11-23 12:29:24 +01:00
|
|
|
$: routeStore.actions.setRouteParams(params || {})
|
2020-11-13 16:42:32 +01:00
|
|
|
|
|
|
|
// Get the screen definition for the current route
|
2020-11-18 20:18:18 +01:00
|
|
|
$: screenDefinition = $screenStore.activeScreen?.props
|
2020-11-17 13:08:24 +01:00
|
|
|
|
2021-05-20 15:47:17 +02:00
|
|
|
// Mark the router as loaded whenever the screen mounts
|
|
|
|
onMount(() => {
|
|
|
|
if (!$routeStore.routerLoaded) {
|
|
|
|
routeStore.actions.setRouterLoaded()
|
|
|
|
}
|
|
|
|
})
|
2020-11-13 16:42:32 +01:00
|
|
|
</script>
|
|
|
|
|
2021-02-10 16:49:23 +01:00
|
|
|
<!-- Ensure to fully remount when screen changes -->
|
|
|
|
{#key screenDefinition?._id}
|
|
|
|
<Provider key="url" data={params}>
|
2021-06-11 09:05:49 +02:00
|
|
|
<Component instance={screenDefinition} />
|
2021-02-10 16:49:23 +01:00
|
|
|
</Provider>
|
|
|
|
{/key}
|