Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show users currently watching device page #1947

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

elinol
Copy link
Contributor

@elinol elinol commented Mar 6, 2025

Adds Phoenix Presence, to application in general and device page specifically.

Tracks user on mount, subscribes to events for device's presence and populates user list on presence diff.

Todo:

  • Better styling on user circles

@elinol
Copy link
Contributor Author

elinol commented Mar 6, 2025

image

@elinol elinol force-pushed the user-presence-on-device-page branch from 0d0f1f7 to e08f285 Compare March 6, 2025 14:15
@joshk
Copy link
Collaborator

joshk commented Mar 6, 2025

This is looking very cool!

I was reading up on Phoenix.Presence myself, to better understand all the bits that were going on, and came across https://hexdocs.pm/phoenix/presence.html#usage-with-liveview

Your approach appears a bit more in line with the channels implementation recommendations. The thing that might be of interested is:

One thing to keep in mind when dealing with LiveView, is that each LiveView is a stateful process, so if we keep the presence state in the LiveView, each LiveView process will contain the full list of online users in memory. Instead, we can keep track of the online users within the Presence process, and pass separate events to the LiveView, which can use a stream to update the online list.

@elinol
Copy link
Contributor Author

elinol commented Mar 7, 2025

I read that too and that was my first approach but I didn't got it working alright. Might be worth giving it another try though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants