fix: clean up someday lists and tasks when disconnecting a calendar provider

Unlink external references (externalId, externalProvider, externalListId)
from someday lists and tasks when their associated calendar connection
is deleted, so orphaned entries don't persist in the UI.

v1.57.8

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
mARTin 2026-03-23 00:21:16 +01:00
parent 3ec5a21714
commit 9e7266053b
2 changed files with 15 additions and 1 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "my-weekly-todo-list", "name": "my-weekly-todo-list",
"version": "1.57.7", "version": "1.57.8",
"description": "A web-based weekly task management application that organizes to-dos and calendar events in a single, intuitive weekly view", "description": "A web-based weekly task management application that organizes to-dos and calendar events in a single, intuitive weekly view",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

View File

@ -190,6 +190,20 @@ export async function DELETE(request: NextRequest) {
where: { id: connectionId, userId: user.id } where: { id: connectionId, userId: user.id }
}); });
if (connection) {
// Unlink someday lists that were synced with this provider
await prisma.somedayList.updateMany({
where: { userId: user.id, externalProvider: connection.provider },
data: { externalId: null, externalProvider: null, lastSyncedAt: null },
});
// Unlink tasks that were synced with this provider
await prisma.task.updateMany({
where: { userId: user.id, externalProvider: connection.provider },
data: { externalId: null, externalProvider: null, externalListId: null, lastSyncedAt: null },
});
}
// Delete the connection // Delete the connection
await prisma.calendarConnection.delete({ await prisma.calendarConnection.delete({
where: { where: {