Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
popover: Fix misleading time description in right side-bar.
Gunnar Samuelsson876dd7ca60aa
diff --git a/web/src/presence.ts b/web/src/presence.tsindex 737d6092889..523b1a9f5c1 100644--- a/web/src/presence.ts+++ b/web/src/presence.ts@@ -96,9 +96,6 @@ export function status_from_raw(raw: RawPresence): PresenceStatus {const idle_timestamp = raw.idle_timestamp;let last_active: number | undefined;- if (active_timestamp !== undefined || idle_timestamp !== undefined) {- last_active = Math.max(active_timestamp ?? 0, idle_timestamp ?? 0);- }/*If the server sends us `active_timestamp`, this@@ -110,6 +107,7 @@ export function status_from_raw(raw: RawPresence): PresenceStatus {timestamp for idle).*/if (age(active_timestamp) < offline_threshold_secs) {+ last_active = active_timestamp;return {status: "active",last_active,@@ -117,12 +115,23 @@ export function status_from_raw(raw: RawPresence): PresenceStatus {}if (age(idle_timestamp) < offline_threshold_secs) {+ last_active = idle_timestamp;return {status: "idle",last_active,};}+ /*+ We always want to prioritize the last time the user+ was active 'active_timestamp' to be displayed in the+ popover. This since it is the most relevant information+ for other users and matches the formatting of the string+ in the popover.+ */++ last_active = active_timestamp ?? idle_timestamp;+return {status: "offline",last_active,diff --git a/web/tests/presence.test.cjs b/web/tests/presence.test.cjsindex 1c38d93890c..3ad3aff97fb 100644--- a/web/tests/presence.test.cjs+++ b/web/tests/presence.test.cjs@@ -321,7 +321,7 @@ test("update_info_from_event", () => {assert.deepEqual(presence.presence_info.get(alice.user_id), {status: "active",- last_active: 510,+ last_active: 500,});info = {