Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show tasks without a time assigned in the all-day section #531

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/calendars/DailyNoteCalendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const getListsUnderHeading = (
if (!headingPos) {
return [];
}

return metadata.listItems?.filter(
(l) =>
headingPos.start.offset < l.position.start.offset &&
Expand All @@ -109,17 +110,24 @@ const getInlineEventFromLine = (
globalAttrs: Partial<OFCEvent>
): OFCEvent | null => {
const attrs = getInlineAttributes(text);
let extraAttrs: any = {};

// Shortcut validation if there are no inline attributes.
// if there are no inline attributes assume this is a task that isn't
// assigned to a time yet and show it in the all-day field so it can be
if (Object.keys(attrs).length === 0) {
return null;
extraAttrs = {
type: "single",
allDay: true,
startTime: (globalAttrs as any).date,
};
}

return validateEvent({
title: text.replace(listRegex, "").replace(fieldRegex, "").trim(),
completed: checkboxTodo(text),
...globalAttrs,
...attrs,
...extraAttrs,
});
};

Expand Down