Take control over your live stream video by running it yourself. Streaming + chat out of the box.
HTML activitypubbroadcastingchatdecentralizedfederationfediversegolanghacktoberfesthlslivelivestreamowncastrtmpself-hostedstreaming-videovideo
Fix chat array not being properly appended to
Gabe Kangasca79e921d426
diff --git a/web/components/chat/ChatContainer/ChatContainer.tsx b/web/components/chat/ChatContainer/ChatContainer.tsxindex f690f6ea35..bb0bcb0847 100644--- a/web/components/chat/ChatContainer/ChatContainer.tsx+++ b/web/components/chat/ChatContainer/ChatContainer.tsx@@ -43,6 +43,7 @@ export default function ChatContainer(props: Props) {showModeratorMenu={isModerator} // Moderators have access to an additional menuhighlightString={usernameToHighlight} // What to highlight in the messagerenderAsPersonallySent={message.user?.id === chatUserId} // The local user sent this message+ key={message.id}/>);case MessageType.NAME_CHANGE:@@ -55,12 +56,13 @@ export default function ChatContainer(props: Props) {const MessagesTable = useMemo(() => (<Virtuoso- style={{ height: '80vh' }}+ style={{ height: '70vh' }}ref={chatContainerRef}- initialTopMostItemIndex={999}+ initialTopMostItemIndex={999} // Force alignment to bottomdata={messages}itemContent={(index, message) => getViewForMessage(message)}- followOutput="smooth"+ followOutput="auto"+ alignToBottom/>),[messages, usernameToHighlight, chatUserId, isModerator],diff --git a/web/components/stores/ClientConfigStore.tsx b/web/components/stores/ClientConfigStore.tsxindex bffe61893e..78bc7a3845 100644--- a/web/components/stores/ClientConfigStore.tsx+++ b/web/components/stores/ClientConfigStore.tsx@@ -20,7 +20,6 @@ import {SocketEvent,} from '../../interfaces/socket-events';-import handleChatMessage from './eventhandlers/handleChatMessage';import handleConnectedClientInfoMessage from './eventhandlers/connected-client-info-handler';import ServerStatusService from '../../services/status-service';import handleNameChangeEvent from './eventhandlers/handleNameChangeEvent';@@ -256,7 +255,8 @@ export function ClientConfigStore() {);break;case MessageType.CHAT:- handleChatMessage(message as ChatEvent, chatMessages, setChatMessages);+ setChatMessages(currentState => [...currentState, message as ChatEvent]);+break;case MessageType.NAME_CHANGE:handleNameChangeEvent(message as ChatEvent, chatMessages, setChatMessages);@@ -269,8 +269,7 @@ export function ClientConfigStore() {const getChatHistory = async () => {try {const messages = await ChatService.getChatHistory(accessToken);- const updatedChatMessages = [...messages, ...chatMessages];- setChatMessages(updatedChatMessages);+ setChatMessages(currentState => [...currentState, ...messages]);} catch (error) {console.error(`ChatService -> getChatHistory() ERROR: \n${error}`);}diff --git a/web/components/stores/eventhandlers/handleChatMessage.ts b/web/components/stores/eventhandlers/handleChatMessage.tsdeleted file mode 100644index ea9e3512c9..0000000000--- a/web/components/stores/eventhandlers/handleChatMessage.ts+++ /dev/null@@ -1,11 +0,0 @@-import { ChatMessage } from '../../../interfaces/chat-message.model';-import { ChatEvent } from '../../../interfaces/socket-events';--export default function handleChatMessage(- message: ChatEvent,- messages: ChatMessage[],- setChatMessages,-) {- const updatedMessages = [...messages, message];- setChatMessages(updatedMessages);-}