From 80e4dc09415a595e183ba5189ddab2c3993b5827 Mon Sep 17 00:00:00 2001 From: Alex Christoffer Rasmussen Date: Thu, 25 Sep 2025 10:49:16 +0200 Subject: [PATCH] Fix: rundown import (#1795) * fix: patch in the active rundown id and title * fix: send a ALL refetch on project patch * fix: load the last used rundown on project patch and not just the first one * chore: lint * chore: clean up and let rundown service send the refetch request * chore: dont destructure rundown --- .../panel/manage-panel/sources-panel/ImportReview.tsx | 8 ++++++-- apps/server/src/api-data/db/db.controller.ts | 1 - .../src/services/project-service/ProjectService.ts | 9 ++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/apps/client/src/features/app-settings/panel/manage-panel/sources-panel/ImportReview.tsx b/apps/client/src/features/app-settings/panel/manage-panel/sources-panel/ImportReview.tsx index ce78814e7..73e0d49f7 100644 --- a/apps/client/src/features/app-settings/panel/manage-panel/sources-panel/ImportReview.tsx +++ b/apps/client/src/features/app-settings/panel/manage-panel/sources-panel/ImportReview.tsx @@ -2,6 +2,7 @@ import { useState } from 'react'; import { CustomFields, Rundown } from 'ontime-types'; import Button from '../../../../../common/components/buttons/Button'; +import useRundown from '../../../../../common/hooks-query/useRundown'; import * as Panel from '../../../panel-utils/PanelUtils'; import PreviewSpreadsheet from './preview/PreviewRundown'; @@ -17,7 +18,7 @@ interface ImportReviewProps { export default function ImportReview(props: ImportReviewProps) { const { rundown, customFields, onFinished, onCancel } = props; - + const { data: currentRundown } = useRundown(); const [loading, setLoading] = useState(false); const { importRundown } = useGoogleSheet(); const resetPreview = useSheetStore((state) => state.resetPreview); @@ -29,9 +30,12 @@ export default function ImportReview(props: ImportReviewProps) { const applyImport = async () => { setLoading(true); + + // we need to import on-top of the currently loaded rundown + // so the id needs to match await importRundown( { - [rundown.id]: rundown, + [currentRundown.id]: { ...rundown, id: currentRundown.id, title: currentRundown.title }, }, customFields, ); diff --git a/apps/server/src/api-data/db/db.controller.ts b/apps/server/src/api-data/db/db.controller.ts index e7ba51718..8bdc41ae1 100644 --- a/apps/server/src/api-data/db/db.controller.ts +++ b/apps/server/src/api-data/db/db.controller.ts @@ -31,7 +31,6 @@ export async function patchPartialProjectFile(req: Request, res: Response) { /** * The user may have multiple rundowns - * We currently ignore all other rundowns + * so attempt to get the one that was used last + * otherwise just pick the first */ - const firstRundown = getFirstRundown(result); + const last = await getLastLoaded(); + const rundownToLoad = + last?.rundownId && last.rundownId in result ? result[last.rundownId] : getFirstRundown(result); - await initRundown(firstRundown, customFields); + await initRundown(rundownToLoad, customFields, true); } const updatedData = await getDataProvider().getData();