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

17 lines
569 B
TypeScript
Raw Normal View History

import { ConnectedClientInfoEvent } from '../../../interfaces/socket-events';
export default function handleConnectedClientInfoMessage(
message: ConnectedClientInfoEvent,
setChatDisplayName: (string) => void,
setChatDisplayColor: (number) => void,
setChatUserId: (number) => void,
setIsChatModerator: (boolean) => void,
) {
const { user } = message;
const { id, displayName, displayColor, scopes } = user;
setChatDisplayName(displayName);
setChatDisplayColor(displayColor);
setChatUserId(id);
2022-06-25 07:53:16 +03:00
setIsChatModerator(scopes?.includes('moderator'));
}