diff --git a/thrimbletrimmer/src/common/chat.tsx b/thrimbletrimmer/src/common/chat.tsx index f5be808..e2964aa 100644 --- a/thrimbletrimmer/src/common/chat.tsx +++ b/thrimbletrimmer/src/common/chat.tsx @@ -1,4 +1,4 @@ -import { Accessor, Component, For, JSX, Show } from "solid-js"; +import { Accessor, Component, createResource, For, Index, JSX, Show, Suspense } from "solid-js"; import { StreamVideoInfo } from "./streamInfo"; import { DateTime } from "luxon"; import { Fragment } from "hls.js"; @@ -148,6 +148,56 @@ function formatDisplayTime(timeSeconds: number): string { return `${hours}:${minutes}:${seconds}.${milliseconds}`; } +export interface ChatDisplayProps { + streamInfo: StreamVideoInfo; + fragments: Accessor; + videoTime: Accessor; +} + +export const ChatDisplay: Component = (props) => { + const streamDataAndFragments = () => { + const fragments = props.fragments(); + if (!fragments || fragments.length === 0) { + return null; + } + return { + streamInfo: props.streamInfo, + fragments: fragments, + }; + }; + const [possibleChatLog] = createResource(streamDataAndFragments, async () => { + const { streamInfo, fragments } = streamDataAndFragments()!; + return await chatData(streamInfo, fragments); + }); + + const chatLog = () => { + const chatLogData = possibleChatLog(); + if (chatLogData) { + return chatLogData; + } + return ChatLog.default(); + }; + + return ( + + + {(item: Accessor, index: number) => { + const chatCommand = item().message.command; + if (chatCommand === "PRIVMSG") { + return ( + + ); + } else if (chatCommand === "USERNOTICE") { + return ; + } else { + return <>; + } + }} + + + ); +}; + export interface ChatMessageProps { chatMessage: ChatMessageData; chatLog: ChatLog; diff --git a/thrimbletrimmer/src/restreamer/Restreamer.tsx b/thrimbletrimmer/src/restreamer/Restreamer.tsx index f764fd8..3cc5732 100644 --- a/thrimbletrimmer/src/restreamer/Restreamer.tsx +++ b/thrimbletrimmer/src/restreamer/Restreamer.tsx @@ -4,7 +4,6 @@ import { createResource, createSignal, For, - Index, onMount, Setter, Show, @@ -21,7 +20,7 @@ import { } from "../common/convertTime"; import { StreamVideoInfo } from "../common/streamInfo"; import { KeyboardShortcuts, StreamTimeSettings, VideoPlayer } from "../common/video"; -import { chatData, ChatLog, ChatMessage, ChatMessageData, SystemMessage } from "../common/chat"; +import { ChatDisplay } from "../common/chat"; export interface DefaultsData { video_channel: string; @@ -153,30 +152,6 @@ const RestreamerWithDefaults: Component = (props) => { return `/frame/${streamInfo.streamName}/source.png?timestamp=${wubloaderTime}`; }; - const streamDataAndFragments = () => { - const streamInfo = streamVideoInfo(); - const fragments = videoFragments(); - if (!fragments || fragments.length === 0) { - return null; - } - return { - streamInfo: streamInfo, - fragments: fragments, - }; - }; - const [possibleChatLog] = createResource(streamDataAndFragments, async () => { - const { streamInfo, fragments } = streamDataAndFragments()!; - return await chatData(streamInfo, fragments); - }); - - const chatLog = () => { - const chatLogData = possibleChatLog(); - if (chatLogData) { - return chatLogData; - } - return ChatLog.default(); - }; - return ( <> = (props) => { Download Current Frame as Image
- - - {(item: Accessor, index: number) => { - const chatCommand = item().message.command; - if (chatCommand === "PRIVMSG") { - return ( - - ); - } else if (chatCommand === "USERNOTICE") { - return ; - } else { - return <>; - } - }} - - +
);