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

19 lines
577 B
TypeScript

import { ConnectedClientInfoEvent } from '../../../interfaces/socket-events';
export function handleConnectedClientInfoMessage(
message: ConnectedClientInfoEvent,
setChatAuthenticated: (boolean) => void,
setCurrentUser: (CurrentUser) => void,
) {
const { user } = message;
const { id, displayName, displayColor, scopes, authenticated } = user;
setChatAuthenticated(authenticated);
setCurrentUser({
id: id.toString(),
displayName,
displayColor,
isModerator: scopes?.includes('MODERATOR'),
});
}
export default handleConnectedClientInfoMessage;