Skip to content

Commit

Permalink
cant add duplicate names on same weekday
Browse files Browse the repository at this point in the history
  • Loading branch information
Kr0nox committed Oct 24, 2023
1 parent 66c15e0 commit f4f687d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions modules/attendancetracker/attendanceTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ export async function addBlock(block: CalendarBlock): Promise<boolean> {
return false;
}
const allBlocks = get("blocks", "timetable") as CalendarBlock[];
if (allBlocks.some(b => { return b.title === block.title && b.weekday === block.weekday; })) {
return false;
}
allBlocks.push(block);
await write("blocks", "timetable", allBlocks);
return true;
Expand All @@ -116,6 +119,9 @@ export async function updateBlock(index: number, block: CalendarBlock): Promise<
if (allBlocks.length <= index) {
return false;
}
if (allBlocks.some(b => { return b.title === block.title && b.weekday === block.weekday; })) {
return false;
}
allBlocks[index] = block;
await write("blocks", "timetable", allBlocks);
return true;
Expand Down

0 comments on commit f4f687d

Please sign in to comment.