Skip to content

Conversation

@raindrift
Copy link
Contributor

@raindrift raindrift commented Jul 9, 2025

Fixes #575

Each tab/window maintains its own separate websocket connection. We were storing a single rtdb path for a user. If a user opened two windows, then closed one, the onDisconnect handler would be called, switching the user to offline even though they still had an open window.

This PR fixes that, by using an rtdb path with a unique id for each connection. The trigger aggregates all documents for a given user to determine if they are online or not. There's also now a scheduled job that removes old records every 72 hours.

I don't know if this fixes every issue with presence detection, but it definitely fixes an issue.

This PR will have a small conflict with #572, since that one moves some of the code that temporarily disables presence detection. So if merging both of them, make sure to update #572 to remove that code (there won't necessarily be a merge conflict).

  • Tests pass
  • Appropriate changes to documentation are included in the PR

@vivtsai
Copy link
Collaborator

vivtsai commented Nov 21, 2025

Thanks (and apologies for the very late review)! Since there are merge conflicts, will close this PR and transfer the logic to a fresh PR that doesn't conflict with main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Users shown as offline when they're actually online

2 participants