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