Search code examples
google-apigoogle-tasks-api

Changing A Tasks Title, or Date doesn't change the Tasks modified time - Google Tasks API


I am trying to troubleshoot why I cannot get changes to Task titles, and dates, from google tasks, based on the query param updatedMin:

In the following scenarios, all Changes made to tasks are done in Google Tasks flyout via calendar.google.com or done via the Android Tasks app.

Fail Scenarios

Fail Scenario 1:

  • I have a Task A in google Tasks with the Title of "foo"

  • I have a datetime called lastSync = 2022-04-04T04:24:02.773Z

  1. I then change a Task A's title to "bar" at 2022-04-04T04:25:12.773Z - minute and 10 seconds greater than lastSync

  2. I then do the following query:

import { google, tasks_v1 } from "googleapis";

const taskClient = google.tasks({ version: "v1", auth: oauth2Client });

 if (list.updated) {
            const updated = GoogleTaskClient.dateFromRfc339(list.updated);
            if (updated > lastSync) {
              const res = await taskClient.tasks.list({
                tasklist: list.id,
                updatedMin: formatRFC3339(lastSync),
                showHidden: true,
                showDeleted: true,
                showCompleted: true,
                maxResults: 100,
              });
}
  1. and the response has Zero items.

Fail Scenario 2:

  • I have a Task A in google Tasks with the Title of "foo"

  • I have a datetime called lastSync = 2022-04-04T04:24:02.773Z

  1. I then change Task A's date at 2022-04-04T04:25:12.773Z - minute and 10 seconds greater than lastSync

  2. run the query

  3. and the response has Zero items.

Success scenarios

Success Scenario 1:

  • I have a Task A in google Tasks with the Title of "foo"

  • I have a datetime called lastSync = 2022-04-04T04:24:02.773Z

  1. I then mark Task A as complete at 2022-04-04T04:25:12.773Z - minute and 10 seconds greater than lastSync

  2. run the query

  3. and the response includes Task A.

Success Scenario 2:

  • I have a Task A in google Tasks with the Title of "foo"

  • I have a datetime called lastSync = 2022-04-04T04:24:02.773Z

  1. I then change a Task A's title to "bar" at 2022-04-04T04:25:12.773Z - minute and 10 seconds greater than lastSync

  2. I then change Task A's date at 2022-04-04T04:25:15.773Z

  3. run the query

  4. and the response has Task A with the changes.

Summary

Changing the status of a Task always results in it being returned by the query, but changes to Date and Title don't appear to work with updatedMin.

Is this a known limitation of the task API - if so can you help me with some references.


Solution

  • I realized my error/ didn't mention this part 🤦‍♂️...

    I was only getting tasks from TaskLists that were updated after the lastSync:

    const taskClient = google.tasks({ version: "v1", auth: oauth2Client });
    
     if (list.updated) {
                const updated = GoogleTaskClient.dateFromRfc339(list.updated);
                if (updated > lastSync) {
                  const res = await taskClient.tasks.list({
                    tasklist: list.id,
                    updatedMin: formatRFC3339(lastSync),
                    showHidden: true,
                    showDeleted: true,
                    showCompleted: true,
                    maxResults: 100,
                  });
    }
    

    The TaskList object from the API has an updated prop - string: Last modification time of the task list (as a RFC 3339 timestamp).

    My error comes from thinking that changing the title of a Task or its time would result in a change to the updated prop of the parent List, but only changing the status of a task, or deleting a task does that or so it appears (I think it changes when order changes as well). Changes to Title, Description, Time, only cause the respective Task's update prop to be updated.

    The docs could clarify that what qualifies as a update to a TaskList: https://developers.google.com/tasks/reference/rest/v1/tasklists#TaskList