raycast / extensions

Everything you need to extend Raycast.
https://developers.raycast.com
MIT License
5.38k stars 3.07k forks source link

[Todoist] Default sorting doesn't work #14319

Open roizner opened 2 months ago

roizner commented 2 months ago

Extension

https://www.raycast.com/doist/todoist

Raycast Version

1.81.2

macOS Version

14.6.1

Description

The order of the tasks (with Default sorting) in lists is incorrect, i.e. it's not the same as in Todoist app.

Steps To Reproduce

  1. Have some number of tasks in the Project / Filter / Sub-tasks.
  2. Use manual sorting in Todoist app and reorder the tasks.
  3. Open the list of tasks in the Raycast extension.

Current Behaviour

The tasks are in some random order.

Expected Behaviour

The tasks should be in the same order as in Todoist.

raycastbot commented 2 months ago

Thank you for opening this issue!

🔔 @thomaslombart @AnishDe12020 @kud @casassg @Princeyadav05 @jfkisafk you might want to have a look.

💡 Author and Contributors commands The author and contributors of `doist/todoist` can trigger bot actions by commenting: - `@raycastbot close this issue` Closes the issue. - `@raycastbot close as not planned` Closes the issue as not planned. - `@raycastbot rename this issue to "Awesome new title"` Renames the issue. - `@raycastbot reopen this issue` Reopens the issue. - `@raycastbot assign me` Assigns yourself to the issue. - `@raycastbot good first issue` Adds the "Good first issue" label to the issue. - `@raycastbot keep this issue open` Make sure the issue won't go stale and will be kept open by the bot.
thomaslombart commented 2 months ago

Could you share some screenshots to see the difference between the tasks in Raycast and Todoist?

roizner commented 2 months ago

For Today tasks in Todoist app (the desired order):

image

in Raycast:

image

For sub-tasks in Todoist app (the desired order):

image

in Raycast:

image
thomaslombart commented 2 months ago

Here's the code we have related to sorting today tasks in the extension:

export function getTasksForTodayOrUpcomingView(tasks: Task[], userId: string) {
  const filteredTasks = tasks.filter((t) => {
    if (!t.due) {
      return false;
    }

    if (t.responsible_uid && t.responsible_uid !== userId) {
      return false;
    }

    return true;
  });

  // Sorts tasks based on the following criteria, in order:
  // 1. Due date type (datetime due dates appear first)
  // 2. Due date and time (earliest first)
  // 3. Priority (highest first)
  // 4. Day order (lowest first)
  return filteredTasks.sort((a, b) => {
    if (!a.due || !b.due) {
      return 0;
    }

    const aIsExactTime = isExactTimeTask(a);
    const bIsExactTime = isExactTimeTask(b);
    if (aIsExactTime !== bIsExactTime) {
      return bIsExactTime ? 1 : -1;
    }

    const bDue = new Date(b.due.date);
    const aDue = new Date(a.due.date);
    if (aDue.getTime() !== bDue.getTime()) {
      return aDue.getTime() - bDue.getTime();
    }

    if (a.priority !== b.priority) {
      return b.priority - a.priority;
    }

    return a.day_order - b.day_order;
  });
}

day_order being "the order of the task inside the Today or Next 7 days view (a number, where the smallest value would place the task at the top)." according to Todoist's docs. I don't see how the code could go wrong in your case, so maybe there's a bug in Todoist's APIs 🤔

roizner commented 2 months ago

The problem I see in Today ordering seems to be about recurrent tasks. Todoist shows them on the top in my case, Raycast shows them on the bottom.

thomaslombart commented 1 month ago

Still, if a task is recurring, the day_order should probably be reflected in both Todoist's UI and API, so I don't think we can do much here apart from contacting their support.

raycastbot commented 8 hours ago

This issue has been automatically marked as stale because it did not have any recent activity.

It will be closed if no further activity occurs in the next 10 days to keep our backlog clean 😊