diff --git a/src/app/stores/facts-store.ts b/src/app/stores/facts-store.ts index 6d76bd9b3..32db6c667 100644 --- a/src/app/stores/facts-store.ts +++ b/src/app/stores/facts-store.ts @@ -19,7 +19,7 @@ export default class FactsStore { facts.forEach((item) => { const updatedItem: FactUpdate = { ...item, - isPersisted: item.id !== 0, + isPersisted: item.id > 0, modelState: ModelState.Updated, }; diff --git a/src/features/AdminPage/NewStreetcode/InterestingFactsBlock/InterestingFactsBlock.component.tsx b/src/features/AdminPage/NewStreetcode/InterestingFactsBlock/InterestingFactsBlock.component.tsx index e63b859d4..52d6fb036 100644 --- a/src/features/AdminPage/NewStreetcode/InterestingFactsBlock/InterestingFactsBlock.component.tsx +++ b/src/features/AdminPage/NewStreetcode/InterestingFactsBlock/InterestingFactsBlock.component.tsx @@ -10,8 +10,8 @@ import InterestingFactAdminItem from "./InterestingFactsAdminItem/InterestingFac import StrictModeDroppable from "@/app/common/components/StrictModeDroppable"; interface Props { - fact?: Fact; - onChange: (field: string, value: any) => void; + fact?: Fact; + onChange: (field: string, value: any) => void; } const InterestingFactsBlock = ({ fact, onChange }: Props) => { @@ -39,12 +39,7 @@ const InterestingFactsBlock = ({ fact, onChange }: Props) => { result.source.index, result.destination!.index ); - - const draggedItem = reorderedItems[result.destination.index]; - if (draggedItem.id < 0) { - draggedItem.id = 0; - } - + factsStore.updateFactMapWithNewOrder(reorderedItems); }; diff --git a/src/features/AdminPage/NewStreetcode/MainNewStreetcode.component.tsx b/src/features/AdminPage/NewStreetcode/MainNewStreetcode.component.tsx index f8174d223..a1a545241 100644 --- a/src/features/AdminPage/NewStreetcode/MainNewStreetcode.component.tsx +++ b/src/features/AdminPage/NewStreetcode/MainNewStreetcode.component.tsx @@ -424,7 +424,9 @@ const NewStreetcode = () => { videos: videosUpdate, relatedFigures: relatedFiguresUpdate, timelineItems: timelineItemStore.getTimelineItemArrayToUpdate, - facts: reindex(factsStore.getFactArrayToUpdate.map((item) => ({ ...item, streetcodeId: parseId }))), + facts: reindex(factsStore.getFactArrayToUpdate.map((item) => ({ ...item, + streetcodeId: parseId, + id: item.id < 0 ? 0 : item.id }))), partners: partnersUpdate, subtitles: subtitleUpdate, text: text.modelState === ModelState.Deleted || (text.title && text.textContent) ? text : null,