Skip to content

Commit

Permalink
fix: improving useless calls to backend
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasz97 committed Sep 24, 2024
1 parent b6ae681 commit ed73f82
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions src/components/timesheet/TimeSheetTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,33 @@ export const TimeSheetTable = component$<TimeSheetTableProps>(
}
timeEntriesState[project.name][date] = hours;

const ignoreChange = () => {
const { hours, date, project, task, startHour, endHour, description } =
timeEntryObject;

if (timeEntriesState[project.name][date] !== hours) return false;

if (hours === 0) return true;

const entryNotChanged = state.dataTimeEntries.find(
(entry) =>
entry.hours === hours &&
entry.date === date &&
entry.project.name === project.name &&
entry.project.type === project.type &&
entry.task === task &&
entry.startHour === startHour &&
entry.endHour === endHour &&
entry.description === description
);

return entryNotChanged;
};

if (ignoreChange()) {
return;
}

updateTimeEntries(timeEntryObject);
});

Expand Down
2 changes: 1 addition & 1 deletion src/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"skill_label": "Skill",
"crew_label": "Crew",
"name_label": "Name",
"effort_table_title": "Oveview effort",
"effort_table_title": "Overview effort",
"effort_table_confirmed": "Confirmed",
"effort_table_tentative": "Tentative",
"effort_table_total": "Total",
Expand Down

0 comments on commit ed73f82

Please sign in to comment.