Demo, all content is generated
Question

Realtime presence shows the same user twice after their phone wakes up

Open · 24 views · asked by elena_p · edited

Small study-room app, a sidebar shows who is online using presence. When someone locks their phone and unlocks it a few minutes later, they appear twice in the list for about 30 seconds, then the old one disappears. I track with channel.track({ user_id, name }) and render Object.values(channel.presenceState()).flat().

Is there a way to make the old entry go away immediately, or should I just dedupe by user_id in the UI?

What I’ve tried

Tried calling untrack on visibilitychange hidden, but on iOS the page is often frozen before that runs. Deduping works visually but feels like a hack.

Comment
Deduping by user_id is what I ended up doing too, since one person with two tabs is also two presences. Curious if there's something cleaner. pawel_z · edited
Good point about two tabs, didn't think of that. Leaving this open in case someone knows about the timeout. elena_p · edited

Activity

20 helpers notified