Skip to content

Commit

Permalink
return null if deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
sinamics committed Mar 10, 2024
1 parent 42e83dc commit 1bc117a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/server/api/routers/networkRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const networkRouter = createTRPCRouter({
*/
const zombieMembers = await fetchZombieMembers(
input.nwid,
membersWithStatusAndPeers,
ztControllerResponse.members,
);

// Generate CIDR options for IP configuration
Expand Down
10 changes: 8 additions & 2 deletions src/server/api/services/memberService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,16 @@ export const syncMemberPeersAndStatus = async (
await addNetworkMember(ctx, updatedMember).catch(console.error);
}

// Return null if the member is deleted.
if (!dbMember) {
return null;
}

// Return the updated member
return updatedMember;
}),
);

// console.log(updatedMembers);
return updatedMembers.filter(Boolean); // Filter out any null values
};

Expand Down Expand Up @@ -166,7 +172,7 @@ export const retrieveActiveMemberFromDatabase = async (
memberId: string,
) => {
const dbMember = await prisma.network_members.findFirst({
where: { nwid, id: memberId },
where: { nwid, id: memberId, deleted: false },
include: { notations: { include: { label: true } } },
});
return dbMember && !dbMember.deleted ? dbMember : null;
Expand Down

0 comments on commit 1bc117a

Please sign in to comment.