Skip to content

Commit

Permalink
cant add duplicate names on same weekday (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kr0nox authored Oct 26, 2023
1 parent 66c15e0 commit d74d9a6
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 d74d9a6

Please sign in to comment.