From d58aa51930c0e30cde1d5c9092d562c88239ab79 Mon Sep 17 00:00:00 2001 From: Guilhem Date: Wed, 9 Oct 2024 20:37:02 +0200 Subject: [PATCH] fix schedules sync --- .../lib/components/RunPageSchedules.svelte | 15 +++++----- .../flows/content/FlowTriggers.svelte | 28 ++----------------- 2 files changed, 9 insertions(+), 34 deletions(-) diff --git a/frontend/src/lib/components/RunPageSchedules.svelte b/frontend/src/lib/components/RunPageSchedules.svelte index c374e3be72..30da3f2dd9 100644 --- a/frontend/src/lib/components/RunPageSchedules.svelte +++ b/frontend/src/lib/components/RunPageSchedules.svelte @@ -2,7 +2,7 @@ import ScheduleEditor from './ScheduleEditor.svelte' import { Button } from './common' import { workspaceStore } from '$lib/stores' - import { ScheduleService, type Schedule } from '$lib/gen' + import { ScheduleService } from '$lib/gen' import { sendUserToast } from '$lib/toast' import { Calendar } from 'lucide-svelte' import Skeleton from './common/skeleton/Skeleton.svelte' @@ -17,7 +17,6 @@ let scheduleEditor: ScheduleEditor - export let schedules: Schedule[] | undefined = undefined export let newFlow: boolean = false $: path && loadSchedule() @@ -42,7 +41,7 @@ async function loadSchedules() { try { - schedules = ( + $schedules = ( await ScheduleService.listSchedules({ workspace: $workspaceStore ?? '', path, @@ -70,7 +69,7 @@ } } - const { primarySchedule } = getContext('FlowEditorContext') + const { primarySchedule, schedules } = getContext('FlowEditorContext') - {#if schedules} - {#if schedules.length == 0} + {#if $schedules} + {#if $schedules?.length == 0 || $schedules == undefined}
No other schedules
{:else}
- {#each schedules as schedule (schedule.path)} -
+ {#each $schedules as schedule (schedule.path)} +
{schedule.path}
{schedule.schedule}
diff --git a/frontend/src/lib/components/flows/content/FlowTriggers.svelte b/frontend/src/lib/components/flows/content/FlowTriggers.svelte index b7a30e378b..5159bb500c 100644 --- a/frontend/src/lib/components/flows/content/FlowTriggers.svelte +++ b/frontend/src/lib/components/flows/content/FlowTriggers.svelte @@ -5,13 +5,11 @@ import EmailTriggerPanel from '$lib/components/details/EmailTriggerPanel.svelte' import RoutesPanel from '$lib/components/triggers/RoutesPanel.svelte' import RunPageSchedules from '$lib/components/RunPageSchedules.svelte' - import { ScheduleService, type Schedule } from '$lib/gen' import { canWrite } from '$lib/utils' - import { userStore, workspaceStore } from '$lib/stores' + import { userStore } from '$lib/stores' import FlowCard from '../common/FlowCard.svelte' - import { onMount, getContext } from 'svelte' + import { getContext } from 'svelte' import type { FlowEditorContext } from '../types' - let schedules: Schedule[] | undefined = undefined export let noEditor: boolean export let newFlow = false @@ -20,27 +18,6 @@ const { pathStore, selectedTrigger } = getContext('FlowEditorContext') $: path = $pathStore - - async function loadSchedules() { - if (!path) return - try { - schedules = ( - await ScheduleService.listSchedules({ - workspace: $workspaceStore ?? '', - path: path, - isFlow: true - }) - ).filter((s) => s.path != path) - } catch (e) { - console.error('impossible to load schedules') - } - } - - onMount(() => { - if (!newFlow) { - loadSchedules() - } - }) @@ -90,7 +67,6 @@ isFlow={true} path={path ?? ''} can_write={canWrite(path, {}, $userStore)} - bind:schedules />
{/if}