diff --git a/src/app/hooks/usePresenceUpdater.ts b/src/app/hooks/usePresenceUpdater.ts index da28812f1..74a57644e 100644 --- a/src/app/hooks/usePresenceUpdater.ts +++ b/src/app/hooks/usePresenceUpdater.ts @@ -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)); };