mirror of
https://github.com/owncast/owncast.git
synced 2024-12-27 19:48:32 +03:00
c563742856
* add pop out chat button * add button to close chat popup * chat is hidden on main interface when a popup chat is open * NameChangeEvent renames clients with the given id if you have two or more owncast windows (or pop-out chats) open, changing your name in 1 client is reflected in all clients. * replace isChatVisible booleans with chatState enum * update stories to use ChatState * fix build tests --------- Co-authored-by: janWilejan <>
18 lines
545 B
TypeScript
18 lines
545 B
TypeScript
import { NameChangeEvent } from '../../../interfaces/socket-events';
|
|
import { CurrentUser } from '../../../interfaces/current-user';
|
|
|
|
export function handleNameChangeEvent(
|
|
message: NameChangeEvent,
|
|
setChatMessages,
|
|
setCurrentUser: (_: (_: CurrentUser) => CurrentUser) => void,
|
|
) {
|
|
setCurrentUser(currentUser =>
|
|
currentUser.id === message.user.id
|
|
? {
|
|
...currentUser,
|
|
displayName: message.user.displayName,
|
|
}
|
|
: currentUser,
|
|
);
|
|
setChatMessages(currentState => [...currentState, message]);
|
|
}
|