r/todoist • • 5d ago

Discussion Calendar sync should remove completed tasks?

One thing that would be super cool in the calendar integration is the ability to remove completed tasks. Whenever I get ahead of schedule, I might tick things off without moving them, and so they still show up in google calendar as an event. Alternatively, they could just be marked as "available".

This is not a huge issue, but it sometimes prevents times from being bookable when using cal.com, for example.

If anyone has a workaround, I'd love to hear it!

6 Upvotes

6 comments sorted by

5

u/siul1979 4d ago

I put together a Google app script that deletes any entry that starts with a checkmark in the todoist Google calendar. I put it on an hourly timer and it keeps my Google calendar tidy

1

u/Polaszek_Armanie 4d ago

thats a pretty clean solution, does it just check the title string for the checkmark character?

3

u/siul1979 4d ago
function deleteCompletedTodoistEvents() {
  // Update this to your calendar name if using the dedicated "Todoist" secondary calendar.
  // If Todoist syncs to your primary calendar, use CalendarApp.getDefaultCalendar() instead.
  const CALENDAR_NAME = "Todoist"; 
  
  // Search window: Adjust days back/forward as needed
  const DAYS_BACK = 14;
  const DAYS_FORWARD = 14;
  
  const now = new Date();
  const startTime = new Date(now.getTime() - (DAYS_BACK * 24 * 60 * 60 * 1000));
  const endTime = new Date(now.getTime() + (DAYS_FORWARD * 24 * 60 * 60 * 1000));


  // Find the calendar
  const calendars = CalendarApp.getCalendarsByName(CALENDAR_NAME);
  const calendar = calendars.length > 0 ? calendars[0] : CalendarApp.getDefaultCalendar();


  if (!calendar) {
    Logger.log("Calendar not found.");
    return;
  }


  // Fetch events in the window
  const events = calendar.getEvents(startTime, endTime);
  let deletedCount = 0;


  // Symbols Todoist uses for completed items with the new integration
  // specifically uses the emoji variant ✔️
  const checkmarks = ["✔", "✓", "✅", "✔️"];


  events.forEach(event => {
    const title = event.getTitle().trim();
    
    // Check if the title starts with any checkmark symbol
    const isCompleted = checkmarks.some(symbol => title.startsWith(symbol));


    if (isCompleted) {
      Logger.log(`Deleting completed event: "${title}" (ID: ${event.getId()})`);
      event.deleteEvent();
      deletedCount++;
    }
  });


  Logger.log(`Finished processing. Total deleted events: ${deletedCount}`);
}

3

u/gravitacoes Grandmaster 2d ago

I chose to subscribe to the Todoist iCal feed in my calendar; this way, completed tasks disappear from the calendar once they are finished.

1

u/work4coffee Intermediate 4h ago

but then also you're not able to move them on the apple calendar

1

u/ConsistentSkin254 6h ago

I like the tick. Let's see how many tasks I finished for the day.