Skip to content

Commit

Permalink
Slightly redone logic and intoduced temp negative values in id
Browse files Browse the repository at this point in the history
  • Loading branch information
yaakymiv committed May 31, 2024
1 parent 79cddd1 commit f233489
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/app/stores/facts-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f233489

Please sign in to comment.