yangjie #22
|
|
@ -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 (
|
||||||
<>
|
<>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue