fix(presence): closing a tab no longer erases your custom status (#339)
CI / Build & Quality Checks (pull_request) Successful in 3m16s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 15s
CI / Playwright smoke (e2e) (pull_request) Successful in 12m20s
CI / Build & Quality Checks (pull_request) Successful in 3m16s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 15s
CI / Playwright smoke (e2e) (pull_request) Successful in 12m20s
The pagehide keepalive write sent { presence: 'offline' } with no
status_msg, which Synapse treats as clearing it, so closing or reloading
any Lotus tab wiped the user's status for everyone (intermittently, as
the 10 s presence rate limit sometimes 429'd the write). It now sends the
current status along with the offline state.
Verified against the local Synapse: with a status set from another
device, two reloads and a tab close keep it (server shows
offline/"Gone fishing" after the close; before, the first reload wiped it).
Fixes #339
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
022e5e6987
commit
e50bd677d6
@@ -167,13 +167,17 @@ export function usePresenceUpdater() {
|
||||
// it isn't usable here. fetch(..., { keepalive: true }) lets the request outlive the
|
||||
// page and is the correct mechanism for an authed endpoint. (keepalive bodies are
|
||||
// capped at 64KB, which this tiny payload is well under.)
|
||||
// [Gitea #339] Synapse treats a missing status_msg as "clear it", so a bare
|
||||
// { presence: 'offline' } wiped the user's custom status for everyone whenever
|
||||
// any tab closed or reloaded. Send the current status along with it.
|
||||
const status = readStatus();
|
||||
fetch(`${baseUrl}/_matrix/client/v3/presence/${encodeURIComponent(userId)}/status`, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ presence: 'offline' }),
|
||||
body: JSON.stringify({ presence: 'offline', ...(status ? { status_msg: status } : {}) }),
|
||||
keepalive: true,
|
||||
}).catch((err) => warnPresenceFailure('offline (pagehide)', err));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user