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

Add Inbox View in Menu Bar Tasks - #17098 #17899

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions extensions/todoist/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Todoist Changelog

## [Added Inbox View in Menu Bar] - {PR MERGE DATE}

Added a new option for Inbox in View under Menu Bar Tasks.

## [Added contributors] - 2025-03-15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: The date '2025-03-15' should be replaced with {PR_MERGE_DATE} to match the template format

Suggested change
## [Added contributors] - 2025-03-15
## [Added contributors] - {PR_MERGE_DATE}


## [Removal of Deadline Feature for Non-Premium Users] - 2025-02-28
Expand Down
4 changes: 4 additions & 0 deletions extensions/todoist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@
"name": "view",
"type": "dropdown",
"data": [
{
"title": "Inbox",
"value": "inbox"
},
Comment on lines +161 to +164
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: The order of views in the menu bar preferences (Inbox, Today, Filter, Upcoming) doesn't match the order in the home command (Inbox, Today, Upcoming, Completed). Consider keeping the order consistent across the extension.

{
"title": "Today",
"value": "today"
Expand Down
30 changes: 27 additions & 3 deletions extensions/todoist/src/menu-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ function MenuBar(props: MenuBarProps) {
const { data: filterTasks, isLoading: isLoadingFilter } = useFilterTasks(view === "filter" ? filter : "");

const tasks = useMemo(() => {
if (view === "inbox") {
const inboxProject = data?.projects.find((p) => p.inbox_project);
return data?.items.filter((t) => t.project_id === inboxProject?.id) ?? [];
}

const tasks = data ? getTasksForTodayOrUpcomingView(data.items, data.user.id) : [];

if (view === "today") {
Expand All @@ -59,6 +64,7 @@ function MenuBar(props: MenuBarProps) {
return isBefore(new Date(t.due.date), dateToCompare);
});
}

return data?.items.filter((t) => t.due?.date) ?? [];
}, [data, upcomingDays, view]);

Expand Down Expand Up @@ -88,19 +94,25 @@ function MenuBar(props: MenuBarProps) {
return "";
}

if (tasks && view !== "filter") {
if (tasks && !["filter"].includes(view)) {
return tasks.length > 0 ? tasks.length.toString() : "🎉";
} else if (filterTasks) {
}

if (filterTasks) {
return filterTasks.length > 0 ? filterTasks.length.toString() : "🎉";
}
}, [focusedTask, tasks, hideMenuBarCount, filterTasks, view, showNextTask, taskWidth]);

let taskView = tasks && <UpcomingView tasks={tasks} data={data} setData={setData} />;
if (view === "today") {
taskView = tasks && <TodayView tasks={tasks} data={data} setData={setData} />;
} else if (view === "filter") {
}
if (view === "filter") {
taskView = <FilterView tasks={filterTasks || []} data={data} setData={setData} />;
}
if (view === "inbox") {
taskView = <InboxView tasks={tasks || []} data={data} setData={setData} />;
}

return (
<MenuBarExtra
Expand Down Expand Up @@ -280,6 +292,18 @@ const UpcomingView = ({ tasks, data, setData }: TaskViewProps): JSX.Element => {
);
};

const InboxView = ({ tasks, data, setData }: TaskViewProps): JSX.Element => {
return tasks.length > 0 ? (
<MenuBarExtra.Section title="Inbox tasks">
{tasks.map((task) => (
<MenuBarTask key={task.id} task={task} data={data} setData={setData} />
))}
</MenuBarExtra.Section>
) : (
<MenuBarExtra.Item title="No tasks in inbox." />
);
};

export default function Command(props: MenuBarProps) {
return (
<View>
Expand Down
Loading