Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
console.log("user has left from all devices", leftPres)
} else {
console.log("user left from a device", leftPres)
}
};
state = Presence.syncState(state, stateFromServer, onJoin, onLeave);
const listBy = (id: string, {metas: [first, ...rest]} : {metas: any[]}) => {
first.count = rest.length + 1;
first.id = id;
return first;
};
const onlineUsers = Presence.list(state, listBy);
}
export const syncPresentUsers = ({ commit }, presences) => {
const presentUsers = [];
Presence.list(presences, (id, { metas: [first] }) => first.user)
.map(user => presentUsers.push(user))
commit(TYPES.ROOM_PRESENCE_UPDATE, presentUsers)
}
retroChannel.on("presence_state", presences => {
const users = Presence.list(presences, (_userToken, presence) => (presence.user))
actions.setUsers(users)
})
interfaceChannel.on('presence_diff', diff => {
presences = Presence.syncDiff(presences, diff)
dispatch(updatePresences(Presence.list(presences, listBy)))
})
const syncPresentUsers = (dispatch, presences) => {
const presentUsers = [];
Presence.list(presences, (id, { metas: [first] }) => first.user)
.map((user) => presentUsers.push(user));
dispatch({ type: 'ROOM_PRESENCE_UPDATE', presentUsers });
};
interfaceChannel.on('presence_state', state => {
presences = Presence.syncState(presences, state)
dispatch(updatePresences(Presence.list(presences, listBy)))
})