Skip to content

Commit

Permalink
refactor: 💡 Code refactoring
Browse files Browse the repository at this point in the history
✅ Closes: #140
  • Loading branch information
CrisGrud committed Nov 6, 2023
1 parent a134be6 commit def605c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/timeline/TimelineContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { DateTime, Interval } from "luxon";
import { addHeaderResource } from "../resources/utils/resources";
import { filterTasks, TaskData, validateTasks } from "../tasks/utils/tasks";
import { DEFAULT_GRID_COLUMN_WIDTH, DEFAULT_GRID_ROW_HEIGHT, MINIMUM_GRID_ROW_HEIGHT } from "../utils/dimensions";
import { logDebug, logError, logWarn } from "../utils/logger";
import { logDebug, logWarn } from "../utils/logger";
import { getValidRangeTime, getValidTime, InternalTimeRange, isValidRangeTime } from "../utils/time";
import { getIntervalFromInternalTimeRange } from "../utils/time";
import { getResolutionData, Resolution, ResolutionData } from "../utils/time-resolution";
Expand Down Expand Up @@ -213,16 +213,18 @@ export const TimelineProvider = ({
const intervalEnd = interval.end!;

let blockStart = intervalStart;

while (blockStart < intervalEnd) {
let blockEnd = blockStart.endOf(unitAbove);

if (blockEnd > intervalEnd) {
blockEnd = intervalEnd;
}

logError("Adding Block", `${blockStart.toFormat("dd/MM/yy HH:mm")} > ${blockEnd.toFormat("dd/MM/yy HH:mm")}`);
blocks.push(Interval.fromDateTimes(blockStart, blockEnd));
blockStart = blockEnd.startOf(unitAbove).plus({ [unitAbove]: 1 });
}

return blocks;
}, [interval, resolution]);

Expand Down

0 comments on commit def605c

Please sign in to comment.