owncast/web/components/stores/eventhandlers/connected-client-info-handler.ts

18 lines
666 B
TypeScript

import { ConnectedClientInfoEvent } from '../../../interfaces/socket-events';
export default function handleConnectedClientInfoMessage(
message: ConnectedClientInfoEvent,
setChatDisplayName: (string) => void,
setChatDisplayColor: (number) => void,
setChatUserId: (number) => void,
setIsChatModerator: (boolean) => void,
setChatAuthenticated: (boolean) => void,
) {
const { user } = message;
const { id, displayName, displayColor, scopes, authenticated } = user;
setChatDisplayName(displayName);
setChatDisplayColor(displayColor);
setChatUserId(id);
setIsChatModerator(scopes?.includes('MODERATOR'));
setChatAuthenticated(authenticated);
}