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

Merged
merged 2 commits into from
Mar 25, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
31 changes: 29 additions & 2 deletions extensions/todoist/src/menu-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function MenuBar(props: MenuBarProps) {
const { view, filter, upcomingDays, hideMenuBarCount, showNextTask, taskWidth } =
getPreferenceValues<Preferences.MenuBar>();
const { data: filterTasks, isLoading: isLoadingFilter } = useFilterTasks(view === "filter" ? filter : "");
const { data: inboxTasks, isLoading: isLoadingInbox } = useFilterTasks(view === "inbox" ? "##Inbox" : "");

const tasks = useMemo(() => {
const tasks = data ? getTasksForTodayOrUpcomingView(data.items, data.user.id) : [];
Expand Down Expand Up @@ -88,10 +89,12 @@ function MenuBar(props: MenuBarProps) {
return "";
}

if (tasks && view !== "filter") {
if (tasks && !["filter", "inbox"].includes(view)) {
return tasks.length > 0 ? tasks.length.toString() : "🎉";
} else if (filterTasks) {
return filterTasks.length > 0 ? filterTasks.length.toString() : "🎉";
} else if (inboxTasks) {
return inboxTasks.length > 0 ? inboxTasks.length.toString() : "🎉";
}
}, [focusedTask, tasks, hideMenuBarCount, filterTasks, view, showNextTask, taskWidth]);

Expand All @@ -100,6 +103,8 @@ function MenuBar(props: MenuBarProps) {
taskView = tasks && <TodayView tasks={tasks} data={data} setData={setData} />;
} else if (view === "filter") {
taskView = <FilterView tasks={filterTasks || []} data={data} setData={setData} />;
} else if (view === "inbox") {
taskView = <InboxView tasks={inboxTasks || []} data={data} setData={setData} />;
}

return (
Expand All @@ -112,7 +117,7 @@ function MenuBar(props: MenuBarProps) {
adjustContrast: false,
},
}}
isLoading={isLoading || isLoadingFilter}
isLoading={isLoading || isLoadingFilter || isLoadingInbox}
title={menuBarExtraTitle}
>
{taskView}
Expand Down Expand Up @@ -280,6 +285,28 @@ const UpcomingView = ({ tasks, data, setData }: TaskViewProps): JSX.Element => {
);
};

const InboxView = ({ tasks, data, setData }: TaskViewProps): JSX.Element => {
const sections = useMemo(() => {
return groupByDates(tasks);
}, [tasks]);

return tasks.length > 0 ? (
<MenuBarExtra.Section title={"Inbox tasks"}>
{sections.map((section, index) => {
return (
<MenuBarExtra.Section title={section.name} key={index}>
{section.tasks.map((task) => (
<MenuBarTask key={task.id} task={task} data={data} setData={setData} />
))}
</MenuBarExtra.Section>
);
})}
</MenuBarExtra.Section>
) : (
<MenuBarExtra.Item title="No tasks in inbox." />
);
};

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