2022-05-25 20:38:40 -07:00
|
|
|
import { ConnectedClientInfoEvent } from '../../../interfaces/socket-events';
|
|
|
|
|
|
|
|
export default function handleConnectedClientInfoMessage(
|
|
|
|
message: ConnectedClientInfoEvent,
|
|
|
|
setChatDisplayName: (string) => void,
|
2022-08-09 19:56:45 -07:00
|
|
|
setChatDisplayColor: (number) => void,
|
2022-06-24 21:30:54 -07:00
|
|
|
setChatUserId: (number) => void,
|
|
|
|
setIsChatModerator: (boolean) => void,
|
2022-08-20 16:13:31 -07:00
|
|
|
setChatAuthenticated: (boolean) => 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;
|
2022-05-25 20:38:40 -07:00
|
|
|
setChatDisplayName(displayName);
|
2022-08-09 19:56:45 -07:00
|
|
|
setChatDisplayColor(displayColor);
|
2022-06-24 21:30:54 -07:00
|
|
|
setChatUserId(id);
|
2022-06-24 21:53:16 -07:00
|
|
|
setIsChatModerator(scopes?.includes('moderator'));
|
2022-08-20 16:13:31 -07:00
|
|
|
setChatAuthenticated(authenticated);
|
2022-05-25 20:38:40 -07:00
|
|
|
}
|