Page load actions now fire on parameter change as well as on mount (#8240)
* Page load actions now fire on parameter change as well as on mount * PR Feedback Co-authored-by: ger <ger@gers-MacBook-Pro.local>
This commit is contained in:
parent
2bce44ae96
commit
0f642f37f4
|
@ -1,5 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import { screenStore, routeStore, builderStore } from "stores"
|
import { screenStore, routeStore, builderStore } from "stores"
|
||||||
|
import { get } from "svelte/store"
|
||||||
import Component from "./Component.svelte"
|
import Component from "./Component.svelte"
|
||||||
import Provider from "./context/Provider.svelte"
|
import Provider from "./context/Provider.svelte"
|
||||||
import { onMount, getContext } from "svelte"
|
import { onMount, getContext } from "svelte"
|
||||||
|
@ -15,24 +16,30 @@
|
||||||
// Get the screen definition for the current route
|
// Get the screen definition for the current route
|
||||||
$: screenDefinition = $screenStore.activeScreen?.props
|
$: screenDefinition = $screenStore.activeScreen?.props
|
||||||
|
|
||||||
onMount(() => {
|
$: runOnLoadActions(params)
|
||||||
// Mark the router as loaded whenever the screen mounts
|
|
||||||
if (!$routeStore.routerLoaded) {
|
|
||||||
routeStore.actions.setRouterLoaded()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enrich and execute and on load actions.
|
// Enrich and execute any on load actions.
|
||||||
// We manually construct the full context here as this component is the
|
// We manually construct the full context here as this component is the
|
||||||
// one that provides the url context, so it is not available in $context yet
|
// one that provides the url context, so it is not available in $context yet
|
||||||
if ($screenStore.activeScreen?.onLoad && !$builderStore.inBuilder) {
|
const runOnLoadActions = params => {
|
||||||
const actions = enrichButtonActions($screenStore.activeScreen.onLoad, {
|
const screenState = get(screenStore)
|
||||||
...$context,
|
|
||||||
|
if (screenState.activeScreen?.onLoad && !get(builderStore).inBuilder) {
|
||||||
|
const actions = enrichButtonActions(screenState.activeScreen.onLoad, {
|
||||||
|
...get(context),
|
||||||
url: params,
|
url: params,
|
||||||
})
|
})
|
||||||
if (actions != null) {
|
if (actions != null) {
|
||||||
actions()
|
actions()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
// Mark the router as loaded whenever the screen mounts
|
||||||
|
if (!$routeStore.routerLoaded) {
|
||||||
|
routeStore.actions.setRouterLoaded()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue