Skip to content
This repository was archived by the owner on Feb 27, 2023. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/shared/comms/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ function processProfileUpdatedMessage(message: Package<proto.AnnounceProfileVers
peerTrackingInfo.lastProfileVersion = message.data.profileVersion

// remove duplicates
ensureTrackingUniqueAndLatest(peerTrackingInfo)
const [_, changed] = ensureTrackingUniqueAndLatest(peerTrackingInfo)
if (!changed) {
return
}

const profileVersion = +message.data.profileVersion

Expand Down
4 changes: 3 additions & 1 deletion packages/shared/comms/peers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,13 @@ export function removeAllPeers() {
*/
export function ensureTrackingUniqueAndLatest(peer: PeerInformation) {
let currentPeer = peer
let changed = false

peerMap.forEach((info, address) => {
if (info.ethereumAddress === currentPeer.ethereumAddress && address !== peer.ethereumAddress) {
if (info.lastProfileVersion < currentPeer.lastProfileVersion) {
removePeerByAddress(address)
changed = true
} else if (info.lastProfileVersion > currentPeer.lastProfileVersion) {
removePeerByAddress(currentPeer.ethereumAddress)

Expand All @@ -201,7 +203,7 @@ export function ensureTrackingUniqueAndLatest(peer: PeerInformation) {
}
})

return currentPeer
return [currentPeer, changed]
}

export function processAvatarVisibility(maxVisiblePeers: number, myAddress: string | undefined) {
Expand Down