mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-20 00:02:19 +00:00
fix: multiple app initializations fixes
This commit is contained in:
@@ -46,12 +46,11 @@
|
||||
? resolvedConfig.defaultRefreshInterval * 1000
|
||||
: parseInt(resolvedConfig.defaultRefreshInterval) * 1000
|
||||
|
||||
if (newInterval !== $recomputeAllContext.interval) {
|
||||
if (newInterval !== $recomputeAllContext.interval && newInterval) {
|
||||
$recomputeAllContext.setInter?.(newInterval)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
{#each Object.keys(components['recomputeallcomponent'].initialData.configuration) as key (key)}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
onMount(() => {
|
||||
if (!$initialized.initializedComponents.includes(id)) {
|
||||
$initialized.initializedComponents = [...$initialized.initializedComponents, id]
|
||||
$initialized = { ...$initialized }
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -543,7 +543,7 @@
|
||||
}
|
||||
|
||||
async function setResult(res: any, jobId: string | undefined) {
|
||||
dispatch('resultSet')
|
||||
dispatch('resultSet', res)
|
||||
const errors = getResultErrors(res)
|
||||
|
||||
if (errors) {
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
|
||||
export let id: string
|
||||
export let result: any = undefined
|
||||
export let initializing: boolean = true
|
||||
export let initializing: boolean | undefined = true
|
||||
export let loading: boolean = false
|
||||
export let extraQueryParams: Record<string, any> = {}
|
||||
export let autoRefresh: boolean = true
|
||||
@@ -96,7 +96,7 @@
|
||||
runnableComponent?.setArgs(value)
|
||||
}
|
||||
|
||||
const { staticExporter, noBackend, componentControl, runnableComponents } =
|
||||
const { staticExporter, initialized, noBackend, componentControl, runnableComponents } =
|
||||
getContext<AppViewerContext>('AppViewerContext')
|
||||
|
||||
if (noBackend && componentInput?.type == 'runnable') {
|
||||
@@ -115,6 +115,14 @@
|
||||
|
||||
if (!(initializing && componentInput?.type === 'runnable' && isRunnableDefined(componentInput))) {
|
||||
initializing = false
|
||||
} else {
|
||||
initializing =
|
||||
initializing == undefined && Object.keys($initialized?.runnableInitialized ?? {}).includes(id)
|
||||
? false
|
||||
: undefined
|
||||
if (result == undefined && !initializing) {
|
||||
result = $initialized.runnableInitialized?.[id]
|
||||
}
|
||||
}
|
||||
|
||||
// We need to make sure that old apps have correct values. Triggerable (button, form, etc) have both autoRefresh and recomputeOnInputChanged set to false
|
||||
@@ -281,7 +289,15 @@
|
||||
on:cancel
|
||||
on:recompute
|
||||
on:argsChanged
|
||||
on:resultSet={() => (initializing = false)}
|
||||
on:resultSet={(e) => {
|
||||
const res = e.detail
|
||||
if (initializing !== false) {
|
||||
console.log('resultSet', id)
|
||||
$initialized.runnableInitialized = { ...$initialized.runnableInitialized, [id]: res }
|
||||
}
|
||||
|
||||
initializing = false
|
||||
}}
|
||||
on:success={(e) => {
|
||||
onSuccess(e.detail)
|
||||
handleSideEffect(true)
|
||||
|
||||
@@ -136,7 +136,11 @@
|
||||
|
||||
const worldStore = buildWorld(context)
|
||||
const previewTheme: Writable<string | undefined> = writable(undefined)
|
||||
const initialized = writable({ initialized: false, initializedComponents: [] })
|
||||
const initialized = writable({
|
||||
initialized: false,
|
||||
initializedComponents: [],
|
||||
runnableInitialized: {}
|
||||
})
|
||||
const panzoomActive = writable(false)
|
||||
|
||||
$secondaryMenuRightStore.isOpen = false
|
||||
|
||||
@@ -126,7 +126,11 @@
|
||||
|
||||
setContext<AppViewerContext>('AppViewerContext', {
|
||||
worldStore: worldStore,
|
||||
initialized: writable({ initialized: false, initializedComponents: [] }),
|
||||
initialized: writable({
|
||||
initialized: false,
|
||||
initializedComponents: [],
|
||||
runnableInitialized: {}
|
||||
}),
|
||||
app: appStore,
|
||||
summary: writable(summary),
|
||||
selectedComponent,
|
||||
|
||||
@@ -13,8 +13,11 @@
|
||||
let firstLoad = false
|
||||
let progressTimer: NodeJS.Timeout | undefined = undefined
|
||||
|
||||
$: !firstLoad && canInitializeAll($initialized?.initializedComponents, $app) && refresh()
|
||||
$: !firstLoad &&
|
||||
canInitializeAll($initialized?.initializedComponents, $app) &&
|
||||
refresh('all initialized')
|
||||
|
||||
// $: console.log('canInitializeAll', firstLoad, $initialized?.initializedComponents)
|
||||
function canInitializeAll(initialized: string[] | undefined, app: App) {
|
||||
// console.log(
|
||||
// 'canInitializeAll',
|
||||
@@ -55,7 +58,7 @@
|
||||
|
||||
onMount(() => {
|
||||
if (appEditorContext) {
|
||||
appEditorContext.refreshComponents.set(refresh)
|
||||
appEditorContext.refreshComponents.set(() => refresh('onClick global'))
|
||||
}
|
||||
document.addEventListener('visibilitychange', visChange)
|
||||
// setTimeout(() => refresh(), 1000)
|
||||
@@ -66,7 +69,7 @@
|
||||
}
|
||||
})
|
||||
|
||||
function onClick(stopAfterClear = false) {
|
||||
function onClick(stopAfterClear: boolean, source: string) {
|
||||
if (timeout) {
|
||||
clearInterval(timeout)
|
||||
timeout = undefined
|
||||
@@ -77,11 +80,13 @@
|
||||
}
|
||||
if (stopAfterClear) return
|
||||
}
|
||||
refresh()
|
||||
if (firstLoad) {
|
||||
refresh('onClick ' + source)
|
||||
}
|
||||
|
||||
if ($recomputeAllContext.interval) {
|
||||
shouldRefresh = true
|
||||
timeout = setInterval(refresh, $recomputeAllContext.interval)
|
||||
timeout = setInterval(() => refresh('onClick interval'), $recomputeAllContext.interval)
|
||||
startProgress()
|
||||
}
|
||||
}
|
||||
@@ -102,15 +107,16 @@
|
||||
}, 100)
|
||||
}
|
||||
|
||||
function setInter(inter: number | undefined) {
|
||||
function setInter(inter: number | undefined, source: string) {
|
||||
$recomputeAllContext.interval = inter
|
||||
onClick(!inter)
|
||||
onClick(!inter, 'setInter ' + source)
|
||||
}
|
||||
|
||||
let refreshing: string[] = []
|
||||
function refresh() {
|
||||
function refresh(reason: string) {
|
||||
let isFirstLoad = false
|
||||
if (!firstLoad) {
|
||||
if (!firstLoad && reason == 'all initialized') {
|
||||
console.log('refresh all first load', reason)
|
||||
$initialized.initialized = true
|
||||
firstLoad = true
|
||||
isFirstLoad = true
|
||||
@@ -118,7 +124,7 @@
|
||||
$recomputeAllContext.loading = true
|
||||
$recomputeAllContext.progress = 100
|
||||
|
||||
console.log('refresh all')
|
||||
console.log('refresh all', reason)
|
||||
refreshing = []
|
||||
const promises = Object.keys($runnableComponents)
|
||||
.flatMap((id) => {
|
||||
@@ -164,28 +170,28 @@
|
||||
if (progressTimer) clearInterval(progressTimer)
|
||||
}
|
||||
} else if (shouldRefresh) {
|
||||
timeout = setInterval(refresh, $recomputeAllContext.interval)
|
||||
timeout = setInterval(() => refresh('onClick interval'), $recomputeAllContext.interval)
|
||||
startProgress()
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
$recomputeAllContext = {
|
||||
onClick,
|
||||
setInter
|
||||
onClick: () => onClick(false, 'allContext'),
|
||||
setInter: (n) => setInter(n, 'all context')
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<RecomputeAllButton
|
||||
on:click={() => onClick()}
|
||||
on:click={() => onClick(false, 'button')}
|
||||
interval={$recomputeAllContext.interval}
|
||||
{refreshing}
|
||||
componentNumber={$recomputeAllContext.componentNumber ?? 0}
|
||||
loading={$recomputeAllContext.loading}
|
||||
progress={$recomputeAllContext.progress}
|
||||
on:setInter={(e) => {
|
||||
setInter(e.detail)
|
||||
onClick(false)
|
||||
setInter(e.detail, 'button setInter')
|
||||
onClick(false, 'button setInter')
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -76,9 +76,9 @@
|
||||
export let component: AppComponent
|
||||
export let render: boolean
|
||||
export let componentContainerHeight: number
|
||||
export let initializing: boolean | undefined = undefined
|
||||
export let errorHandledByComponent: boolean
|
||||
export let inlineEditorOpened: boolean
|
||||
export let initializing: boolean | undefined = undefined
|
||||
</script>
|
||||
|
||||
{#if component.type === 'displaycomponent'}
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
export let moveMode: string | undefined = undefined
|
||||
export let componentDraggedId: string | undefined = undefined
|
||||
export let render: boolean = false
|
||||
|
||||
let initializing: boolean | undefined
|
||||
|
||||
const { mode, app, hoverStore, connectingInput } =
|
||||
getContext<AppViewerContext>('AppViewerContext')
|
||||
|
||||
@@ -31,8 +34,6 @@
|
||||
$: ismoving =
|
||||
movingcomponents != undefined && $mode == 'dnd' && $movingcomponents?.includes(component.id)
|
||||
|
||||
let initializing: boolean | undefined = undefined
|
||||
|
||||
let errorHandledByComponent: boolean = false
|
||||
let componentContainerHeight: number = 0
|
||||
let componentContainerWidth: number = 0
|
||||
|
||||
@@ -200,6 +200,7 @@ export type AppViewerContext = {
|
||||
initialized: Writable<{
|
||||
initializedComponents: string[]
|
||||
initialized: boolean
|
||||
runnableInitialized: Record<string, any>
|
||||
}>
|
||||
selectedComponent: Writable<string[] | undefined>
|
||||
mode: Writable<EditorMode>
|
||||
|
||||
Reference in New Issue
Block a user