Skip to content

Commit 1dd2881

Browse files
committed
add ability to have multiple events with the same name on the same day.
1 parent 9601cb5 commit 1dd2881

3 files changed

Lines changed: 22 additions & 3 deletions

File tree

src/calendars/FullNoteCalendar.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ const basenameFromEvent = (event: OFCEvent): string => {
99
switch (event.type) {
1010
case undefined:
1111
case "single":
12+
const startTime = event.startTime?.replace(":", "-") ?? "";
13+
const endTime = event.endTime?.replace(":", "-") ?? "";
14+
15+
if (startTime && endTime) {
16+
return `${event.date} ${startTime} ${endTime} ${event.title}`;
17+
}
18+
1219
return `${event.date} ${event.title}`;
1320
case "recurring":
1421
return `(Every ${event.daysOfWeek.join(",")}) ${event.title}`;

src/types/schema.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const ParsedDate = z.string();
2626
// return stripTime(parsed);
2727
// });
2828

29-
export const ParsedTime = z.string();
29+
export const ParsedTime = z.string().nullable().optional();
3030
// z.string().transform((val, ctx) => {
3131
// let parsed = DateTime.fromFormat(val, "h:mm a");
3232
// if (parsed.invalidReason) {
@@ -71,6 +71,8 @@ export const EventSchema = z.discriminatedUnion("type", [
7171
completed: ParsedDate.or(z.literal(false))
7272
.or(z.literal(null))
7373
.optional(),
74+
startTime: ParsedTime,
75+
endTime: ParsedTime,
7476
}),
7577
z.object({
7678
type: z.literal("recurring"),
@@ -96,7 +98,13 @@ export function parseEvent(obj: unknown): OFCEvent {
9698
if (typeof obj !== "object") {
9799
throw new Error("value for parsing was not an object.");
98100
}
99-
const objectWithDefaults = { type: "single", allDay: false, ...obj };
101+
const objectWithDefaults = {
102+
type: "single",
103+
allDay: false,
104+
startTime: null,
105+
endTime: null,
106+
...obj,
107+
};
100108
return {
101109
...CommonSchema.parse(objectWithDefaults),
102110
...TimeSchema.parse(objectWithDefaults),

src/ui/components/EditEvent.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,11 @@ export const EditEvent = ({
167167
...{ title },
168168
...(allDay
169169
? { allDay: true }
170-
: { allDay: false, startTime: startTime || "", endTime }),
170+
: {
171+
allDay: false,
172+
startTime: startTime || "",
173+
endTime: endTime || "",
174+
}),
171175
...(isRecurring
172176
? {
173177
type: "recurring",

0 commit comments

Comments
 (0)