refactor: code clean up
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -2,7 +2,6 @@ import type { EntityObject } from '@ChronoManager/models/entity'
|
||||
import type { EventObject } from '@ChronoManager/models/event'
|
||||
import type { EventMutationObject } from '@ChronoManager/models/event-mutation'
|
||||
import type { CalendarInstance } from '../types/instance'
|
||||
import type { VisibleDateRange } from '../types'
|
||||
import { parseCalendarDate, shiftLocalDays, startOfLocalDay } from './date'
|
||||
import { EpochSpan } from '@/types/date'
|
||||
|
||||
@@ -96,7 +95,7 @@ function materializeInstance(
|
||||
durationDays: number | null,
|
||||
recurring: boolean,
|
||||
mutation: EventMutationObject | undefined,
|
||||
range?: VisibleDateRange,
|
||||
range?: EpochSpan,
|
||||
): CalendarInstance | null {
|
||||
if (mutation?.mutationExclusion === true) return null
|
||||
|
||||
@@ -208,7 +207,7 @@ function expandWeekly(
|
||||
start: Date,
|
||||
durationMs: number,
|
||||
durationDays: number | null,
|
||||
range: VisibleDateRange,
|
||||
range: EpochSpan,
|
||||
mutations: Map<number, EventMutationObject>,
|
||||
): CalendarInstance[] {
|
||||
const pattern = (entity.properties as EventObject).pattern!
|
||||
@@ -227,13 +226,13 @@ function expandWeekly(
|
||||
|
||||
while (true) {
|
||||
const intervalWeekStart = shiftLocalDays(weekStart, week * interval * 7)
|
||||
if (intervalWeekStart.getTime() >= range.endMs) break
|
||||
if (intervalWeekStart.getTime() >= range.end) break
|
||||
|
||||
for (const weekday of weekdays) {
|
||||
const candidate = shiftLocalDays(intervalWeekStart, weekday - 1)
|
||||
const candidateMs = candidate.getTime()
|
||||
if (candidateMs < start.getTime()) continue
|
||||
if (candidateMs >= range.endMs) return instances
|
||||
if (candidateMs >= range.end) return instances
|
||||
if (concludesMs !== null && candidateMs > concludesMs) return instances
|
||||
|
||||
occurrenceCount += 1
|
||||
|
||||
Reference in New Issue
Block a user