mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-09 17:33:55 +00:00
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
This commit is contained in:
+6
-2
@@ -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,
|
||||
);
|
||||
|
||||
@@ -31,7 +31,6 @@ export async function patchPartialProjectFile(req: Request, res: Response<Databa
|
||||
};
|
||||
|
||||
const newData = await projectService.patchCurrentProject(patchDb);
|
||||
|
||||
res.status(200).send(newData);
|
||||
} catch (error) {
|
||||
const message = getErrorMessage(error);
|
||||
|
||||
@@ -323,11 +323,14 @@ export async function patchCurrentProject(data: Partial<DatabaseModel>) {
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
Reference in New Issue
Block a user