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,
|
|
|
|
setChatDisplayName: (string) => void,
|
2022-08-10 05:56:45 +03:00
|
|
|
setChatDisplayColor: (number) => void,
|
2022-06-25 07:30:54 +03:00
|
|
|
setChatUserId: (number) => void,
|
|
|
|
setIsChatModerator: (boolean) => void,
|
2022-08-21 02:13:31 +03:00
|
|
|
setChatAuthenticated: (boolean) => 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;
|
2022-05-26 06:38:40 +03:00
|
|
|
setChatDisplayName(displayName);
|
2022-08-10 05:56:45 +03:00
|
|
|
setChatDisplayColor(displayColor);
|
2022-06-25 07:30:54 +03:00
|
|
|
setChatUserId(id);
|
2022-08-23 05:23:06 +03:00
|
|
|
setIsChatModerator(scopes?.includes('MODERATOR'));
|
2022-08-21 02:13:31 +03:00
|
|
|
setChatAuthenticated(authenticated);
|
2022-05-26 06:38:40 +03:00
|
|
|
}
|
2022-09-07 10:00:28 +03:00
|
|
|
export default handleConnectedClientInfoMessage;
|