owncast/web/components/stores/eventhandlers/connected-client-info-handler.ts
2022-06-24 21:53:16 -07:00

14 lines
477 B
TypeScript

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