From 41c79a13b4fa7f38847efcd31f36affc24d47175 Mon Sep 17 00:00:00 2001 From: Curry Yang <163384738+CurryYangxx@users.noreply.github.com> Date: Wed, 29 May 2024 17:30:43 +0800 Subject: [PATCH] fix: project with null remoteId don't need to be updated (#7464) * fix: project with null remoteId don't need to be updated * fix: add detailed comments --- packages/insomnia/src/ui/routes/project.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/insomnia/src/ui/routes/project.tsx b/packages/insomnia/src/ui/routes/project.tsx index 5fc1bfc8be..9d2ca2de9e 100644 --- a/packages/insomnia/src/ui/routes/project.tsx +++ b/packages/insomnia/src/ui/routes/project.tsx @@ -186,8 +186,13 @@ async function syncTeamProjects({ const removedRemoteProjects = await database.find(models.project.type, { // filter by this organization so no legacy data can be accidentally removed, because legacy had null parentId parentId: organizationId, - // Remote ID is not in the list of remote projects - remoteId: { $nin: teamProjects.map(p => p.id) }, + // Remote ID is not in the list of remote projects. + // add `$ne: null` condition because if remoteId is already null, we dont need to remove it again. + // nedb use append-only format, all updates and deletes actually result in lines added + remoteId: { + $nin: teamProjects.map(p => p.id), + $ne: null, + }, }); await Promise.all(removedRemoteProjects.map(async prj => {