stream-chat-js
stream-chat-js copied to clipboard
Presence showing true then immediately false
I got over the hurdle of being able to listen to presence changes but it looks like the ws messages are immediately showing the users as offline milliseconds after showing online. Any tips?
Uploading video now showing websocket messages:
https://www.youtube.com/watch?v=MeyE6O5I8rY
Where I'm listening for presence:
export const ChatChannelSetter: FC<ChatChannelSetterProps> = (properties) => {
const { children, channelInit } = properties
const client = useChatClient()
const [, setChannel] = useChannelState()
const { type, id, data } = channelInit
useEffect(() => {
const loadChat = async () => {
if (client) {
const channel = client.channel(type, id, data)
await channel.watch({ presence: true })
setChannel(channel)
}
}
loadChat()
}, [type, id, data, client, setChannel])
return <>{children}</>
}
Where I'm listening to the event:
useEffect(() => {
const updateChannelUsers = (event?: Event) => {
console.log('JOSH: user presence changed', event)
if (!event || channel.state.members[event.user?.id] !== undefined) {
setChannelUsers(
Object.values(channel.state.members).map((user) => ({
name: user.user_id!,
online: !!user.user?.online,
}))
)
}
}
updateChannelUsers()
client.on('user.presence.changed', updateChannelUsers)
return () => {
client.off('user.presence.changed', updateChannelUsers)
}
}, [client, channel])
I'm having the same issue. I also checked users' online status through Stream dashboard, but all the users are shown as offline. It was working a couple of weeks ago, and I haven't made any changes since then.
I'm having the same issue. I also checked users' online status through Stream dashboard, but all the users are shown as offline. It was working a couple of weeks ago, and I haven't made any changes since then.
I am also facing the same issue.
I'm having the same issue. I also checked users' online status through Stream dashboard, but all the users are shown as offline. It was working a couple of weeks ago, and I haven't made any changes since then.
It seems to be working now.
@ jmckenney I'm closing this issue. It works for @onurarrii and myself locally. Don't hesitate to contact us in the future may you be facing this or any other issues.