Description
Is your feature request related to a problem? Please describe.
I'm using @liveblocks/client
and @liveblocks/react
to add Liveblocks to my React app. In this app, I have a list of all rooms on a page which should display the avatars of people in each room. To do this, I'm using the API endpoint (https://api.liveblocks.io/v2/rooms/{roomId}/active_users).
To display the avatars of users in each room, I was expecting to get the info
field associated with each user in the API response but the API did not return the info
field as I had not set any user information. However, it seems like I can only set the userInfo
on the server using the authorize()
function. Is there a way to set the userInfo
on the client? Is there a reason why this is restricted to only the server?
Describe the solution you'd like
Similar to how we can set the initial presence of a user when they join in the <RoomProvider>
, can we have another prop such as userInfo
to set the user information? Here's an example of how I envision this to be:
//Logged-in user's details can be accessed in user
const { user } = useUser();
<RoomProvider
id={idFromUrl}
userInfo={{ name: user.name, avatar: user.avatar }}
initialPresence={{ cursor: { x: 0, y: 0 } }}
>
<Room />
</RoomProvider>
Alternatively, is there a possibility of adding the userInfo
as an optional parameter while calling client.enter()
from @liveblocks/client
like this:
const room = client.enter("my-room", {
initialPresence: { cursor: null },
initialStorage: { todos: new LiveList() },
userInfo: { name: user.name, avatar: user.avatar }
});