2022-05-25 20:38:40 -07:00
|
|
|
import { ConnectedClientInfoEvent } from '../../../interfaces/socket-events';
|
|
|
|
|
2022-09-07 09:00:28 +02:00
|
|
|
export function handleConnectedClientInfoMessage(
|
2022-05-25 20:38:40 -07:00
|
|
|
message: ConnectedClientInfoEvent,
|
2022-08-20 16:13:31 -07:00
|
|
|
setChatAuthenticated: (boolean) => void,
|
2022-10-10 16:26:09 -07:00
|
|
|
setCurrentUser: (CurrentUser) => void,
|
2022-05-25 20:38:40 -07:00
|
|
|
) {
|
|
|
|
const { user } = message;
|
2022-08-20 16:13:31 -07:00
|
|
|
const { id, displayName, displayColor, scopes, authenticated } = user;
|
|
|
|
setChatAuthenticated(authenticated);
|
2022-10-10 16:26:09 -07:00
|
|
|
|
|
|
|
setCurrentUser({
|
|
|
|
id: id.toString(),
|
|
|
|
displayName,
|
|
|
|
displayColor,
|
|
|
|
isModerator: scopes?.includes('MODERATOR'),
|
|
|
|
});
|
2022-05-25 20:38:40 -07:00
|
|
|
}
|