From a2ab22f50bc20e22122d08e879035a64330ab31b Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 24 Nov 2024 21:13:48 +0100 Subject: [PATCH] fix lastSeen logic --- ui/src/room-view.ts | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/ui/src/room-view.ts b/ui/src/room-view.ts index 1662706..6d6f1d3 100644 --- a/ui/src/room-view.ts +++ b/ui/src/room-view.ts @@ -1107,7 +1107,7 @@ export class RoomView extends LitElement { knownAgents[agentB64] = { pubkey: agentB64, type: 'told', - lastSeen: agentInfo.lastSeen, + lastSeen: undefined, // We did not receive a Pong from them directly appVersion: agentInfo.appVersion, }; } @@ -1581,7 +1581,22 @@ export class RoomView extends LitElement { .map(agent => encodeHashToBase64(agent)) .forEach(agentB64 => { if (agentB64 !== myPubKeyB64) { - knownAgents[agentB64] = { pubkey: agentB64, type: 'known' }; + const alreadyKnown = knownAgents[agentB64]; + if (alreadyKnown && alreadyKnown.type !== 'known') { + knownAgents[agentB64] = { + pubkey: agentB64, + type: 'known', + lastSeen: alreadyKnown.lastSeen, + appVersion: alreadyKnown.appVersion, + }; + } else if (!alreadyKnown) { + knownAgents[agentB64] = { + pubkey: agentB64, + type: 'known', + lastSeen: undefined, + appVersion: undefined, + }; + } } }); this._knownAgents = knownAgents; @@ -2213,7 +2228,9 @@ export class RoomView extends LitElement { knownAgents[pubkeyb64].type === 'told' ); - const lastSeen = knownAgents ? knownAgents[pubkeyb64].lastSeen : undefined; + const lastSeen = knownAgents + ? knownAgents[pubkeyb64].lastSeen + : undefined; return html`