yangjie #22

Merged
yangqiang merged 99 commits from yangjie into master 2024-10-22 16:11:46 +08:00
1 changed files with 11 additions and 11 deletions
Showing only changes of commit 1bfbb47e95 - Show all commits

View File

@ -8,17 +8,16 @@ const ChatSmallWindow: React.FC = () => {
const [isExpand, setIsExpand] = useState(false) const [isExpand, setIsExpand] = useState(false)
const channel = new BroadcastChannel('meeting_channel'); const channel = new BroadcastChannel('meeting_channel');
useEffect(() => { useEffect(() => {
let time: NodeJS.Timeout;
time = setInterval(() => {
setChatLists((res: any) => {
return res.length ? res.slice(0, -1) : res
})
}, 10000)
channel.onmessage = function (event) { channel.onmessage = function (event) {
const { type, chatListIten } = event.data; const { type, chatListIten } = event.data;
switch (type) { switch (type) {
case 'chatListIten': case 'chatListIten':
setChatLists((newChatList: any) => [chatListIten, ...newChatList]) setChatLists((newChatList: any) => {
chatListIten.timer = setTimeout(() => {
removeItemByIndex();
}, 3000);
return [chatListIten, ...newChatList]
})
setTimeout(() => { setTimeout(() => {
const chatSmallWindowView = document.getElementById('chatSmallWindowView') as HTMLElement; const chatSmallWindowView = document.getElementById('chatSmallWindowView') as HTMLElement;
if (chatSmallWindowView) { if (chatSmallWindowView) {
@ -28,11 +27,12 @@ const ChatSmallWindow: React.FC = () => {
break; break;
} }
} }
return () => {
clearTimeout(time)
}
}, []); }, []);
const removeItemByIndex = () => {
setChatLists((res: any) => {
return res.slice(0, -1)
})
}
return ( return (
<> <>