diff --git a/src/assets/images/chathistory/chathistory_toggle.png b/src/assets/images/chathistory/chathistory_toggle.png new file mode 100644 index 0000000..ac3bbd5 Binary files /dev/null and b/src/assets/images/chathistory/chathistory_toggle.png differ diff --git a/src/components/chat-history/ChatHistoryView.scss b/src/components/chat-history/ChatHistoryView.scss index f18f91b..28a13cc 100644 --- a/src/components/chat-history/ChatHistoryView.scss +++ b/src/components/chat-history/ChatHistoryView.scss @@ -1,4 +1,37 @@ .nitro-chat-history { - width: $chat-history-width; - height: $chat-history-height; -} + background-color: #000000cc; + position: absolute; + padding-right: 20px; + top: 0.5px; /* Adjusted to give more space at the top */ + bottom: 0; + height: 75%; + left: 0; + width: 400px; + border-right: 1px solid #000; + border-bottom: 1px solid #000; + -webkit-box-shadow: inset -2px 0px 0px 0px #34322d, inset 0px -2px 0px 0px #34322d; + box-shadow: inset -2px 0px 0px 0px #34322d, inset 0px -2px 0px 0px #34322d; + border-bottom-right-radius: 10px; + + .chat-history-content { + width: 100%; + background-color: #2e2e2c4f; + border-right: 1px solid #3b3933; + padding-bottom: 60px; + } + + .chat-history-content .p-2 { + padding: 10px; + } + + .chat-toggle { + background-image: url(@/assets/images/chathistory/chathistory_toggle.png); + width: 15px; + height: 63px; + cursor: pointer; + position: absolute; + left: 100%; + bottom: 140px; + border-left: 1px solid black; + } +} \ No newline at end of file diff --git a/src/components/chat-history/ChatHistoryView.tsx b/src/components/chat-history/ChatHistoryView.tsx index b34e078..4755a9f 100644 --- a/src/components/chat-history/ChatHistoryView.tsx +++ b/src/components/chat-history/ChatHistoryView.tsx @@ -1,15 +1,17 @@ import { ILinkEventTracker } from '@nitrots/nitro-renderer'; import { FC, useEffect, useMemo, useRef, useState } from 'react'; import { AddEventLinkTracker, ChatEntryType, LocalizeText, RemoveLinkEventTracker } from '../../api'; -import { Flex, InfiniteScroll, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../common'; +import { Column, Flex, InfiniteScroll, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text, Button } from '../../common'; import { useChatHistory, useOnClickChat } from '../../hooks'; +import { motion, AnimatePresence } from 'framer-motion'; export const ChatHistoryView: FC<{}> = props => { - const { chatHistory = [] } = useChatHistory(); + const { chatHistory = [], clearChatHistory } = useChatHistory(); const [ isVisible, setIsVisible ] = useState(false); - const { onClickChat = null } = useOnClickChat(); + const { onClickChat = null } = useOnClickChat(); const [ searchText, setSearchText ] = useState(''); + const elementRef = useRef(null); const filteredChatHistory = useMemo(() => @@ -21,6 +23,13 @@ export const ChatHistoryView: FC<{}> = props => return chatHistory.filter(entry => ((entry.message && entry.message.toLowerCase().includes(text))) || (entry.name && entry.name.toLowerCase().includes(text))); }, [ chatHistory, searchText ]); + const handleClearHistory = () => + { + if (clearChatHistory) { + clearChatHistory(); + } + }; + useEffect(() => { if(elementRef && elementRef.current && isVisible) elementRef.current.scrollTop = elementRef.current.scrollHeight; @@ -32,9 +41,9 @@ export const ChatHistoryView: FC<{}> = props => linkReceived: (url: string) => { const parts = url.split('/'); - + if(parts.length < 2) return; - + switch(parts[1]) { case 'show': @@ -56,42 +65,61 @@ export const ChatHistoryView: FC<{}> = props => return () => RemoveLinkEventTracker(linkTracker); }, []); - if(!isVisible) return null; - return ( - - setIsVisible(false) }/> - - setSearchText(event.target.value) } /> - - { - return ( - - { row.timestamp } - { (row.type === ChatEntryType.TYPE_CHAT) && -
- { (row.style === 0) && -
} -
-
- { row.imageUrl && (row.imageUrl.length > 0) && -
} -
-
- - onClickChat(e) }/> -
-
-
} - { (row.type === ChatEntryType.TYPE_ROOM_INFO) && - <> - - { row.name } - } - - ) - } } /> - - + + { isVisible && ( + + + + + + + + + { + return ( + + {row.timestamp} + { (row.type === ChatEntryType.TYPE_CHAT) && +
+ { (row.style === 0) && +
} +
+
+ { row.imageUrl && (row.imageUrl.length > 0) && +
} +
+
+ + onClickChat(e)} /> +
+
+
} + { (row.type === ChatEntryType.TYPE_ROOM_INFO) && + <> + + {row.name} + } + + ) + }} + /> + + + setIsVisible(false)} /> + + + )} + ); -} +}; \ No newline at end of file diff --git a/src/hooks/chat-history/useChatHistory.ts b/src/hooks/chat-history/useChatHistory.ts index 4c0aa03..83c9ad0 100644 --- a/src/hooks/chat-history/useChatHistory.ts +++ b/src/hooks/chat-history/useChatHistory.ts @@ -65,6 +65,12 @@ const useChatHistoryState = () => }); } + const clearChatHistory = () => + { + setChatHistory([]); + CHAT_HISTORY_COUNTER = 0; + }; + useRoomSessionManagerEvent(RoomSessionEvent.STARTED, event => setNeedsRoomInsert(true)); useMessageEvent(GetGuestRoomResultEvent, event => @@ -99,7 +105,7 @@ const useChatHistoryState = () => addMessengerEntry({ id: -1, webId: parser.senderId, entityId: -1, name: '', message: parser.messageText, roomId: -1, timestamp: MessengerHistoryCurrentDate(), type: ChatEntryType.TYPE_IM }); }); - return { addChatEntry, chatHistory, roomHistory, messengerHistory }; + return { addChatEntry, chatHistory, roomHistory, messengerHistory, clearChatHistory }; } -export const useChatHistory = () => useBetween(useChatHistoryState); +export const useChatHistory = () => useBetween(useChatHistoryState); \ No newline at end of file