diff --git a/package.json b/package.json index de693fb..4993532 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "my-weekly-todo-list", - "version": "1.57.2", + "version": "1.57.3", "description": "A web-based weekly task management application that organizes to-dos and calendar events in a single, intuitive weekly view", "main": "index.js", "scripts": { diff --git a/src/app/api/tasks/sync/route.ts b/src/app/api/tasks/sync/route.ts index 91775d6..396782a 100644 --- a/src/app/api/tasks/sync/route.ts +++ b/src/app/api/tasks/sync/route.ts @@ -206,7 +206,20 @@ export async function GET(req: NextRequest) { } } } catch (listError: any) { - if (listError?.code === 429 || listError?.status === 429) { + if (listError?.code === 404 || listError?.status === 404) { + console.warn(`Google Tasks list ${listId} not found (deleted?), cleaning up local references`); + // Soft-delete local tasks linked to this deleted list + const result = await prisma.task.updateMany({ + where: { userId: user.id, externalProvider: 'google', externalListId: listId, deletedAt: null }, + data: { deletedAt: new Date() }, + }); + deleted += result.count; + // Unlink the synced someday list + await prisma.somedayList.updateMany({ + where: { userId: user.id, externalProvider: 'google', externalId: listId }, + data: { externalId: null, externalProvider: null }, + }); + } else if (listError?.code === 429 || listError?.status === 429) { console.warn(`Google Tasks quota exceeded for list ${listId}, skipping`); } else { console.error(`Error syncing Google list ${listId}:`, listError);