Skip to content

Commit

Permalink
update the db online status
Browse files Browse the repository at this point in the history
  • Loading branch information
sinamics committed Aug 22, 2024
1 parent 052bbfa commit 630cc45
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/server/api/services/memberService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,17 @@ export const syncMemberPeersAndStatus = async (
// Update the connection status
updatedMember.conStatus = determineConnectionStatus(updatedMember);

// Check if the member is connected and has peers
const memberIsOnline =
Object.keys(updatedMember.peers).length > 0 && updatedMember.conStatus !== 0;

// Create the object with the data to be updated
const updateData: Partial<network_members> = {
id: updatedMember.id,
address: updatedMember.address,
online: memberIsOnline,
};

// Check if the member is connected and has peers, if so, update the lastSeen
const memberIsOnline =
Object.keys(updatedMember.peers).length > 0 && updatedMember.conStatus !== 0;

// add lastSeen to updateData if the member is connected
if (memberIsOnline) {
updateData.lastSeen = new Date();
Expand Down

0 comments on commit 630cc45

Please sign in to comment.