mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-27 08:00:51 +01:00
Fix dumb room-tools timeout issue
This commit is contained in:
parent
77819a7e2b
commit
a4c0492034
@ -1,6 +1,6 @@
|
|||||||
import { GetGuestRoomResultEvent, RoomLikeRoomComposer } from '@nitrots/nitro-renderer';
|
import { GetGuestRoomResultEvent, RoomLikeRoomComposer } from '@nitrots/nitro-renderer';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { FC, useCallback, useState } from 'react';
|
import { FC, useCallback, useEffect, useState } from 'react';
|
||||||
import { LocalizeText, RoomWidgetZoomToggleMessage } from '../../../../api';
|
import { LocalizeText, RoomWidgetZoomToggleMessage } from '../../../../api';
|
||||||
import { NavigatorEvent } from '../../../../events';
|
import { NavigatorEvent } from '../../../../events';
|
||||||
import { ChatHistoryEvent } from '../../../../events/chat-history/ChatHistoryEvent';
|
import { ChatHistoryEvent } from '../../../../events/chat-history/ChatHistoryEvent';
|
||||||
@ -53,38 +53,32 @@ export const RoomToolsWidgetView: FC<{}> = props =>
|
|||||||
{
|
{
|
||||||
const parser = event.getParser();
|
const parser = event.getParser();
|
||||||
|
|
||||||
let updated = false;
|
if(roomName !== parser.data.roomName) setRoomName(parser.data.roomName);
|
||||||
|
|
||||||
if(roomName !== parser.data.roomName)
|
if(roomOwner !== parser.data.ownerName) setRoomOwner(parser.data.ownerName);
|
||||||
{
|
|
||||||
updated = true;
|
|
||||||
setRoomName(parser.data.roomName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(roomOwner !== parser.data.ownerName)
|
if(roomTags !== parser.data.tags) setRoomTags(parser.data.tags);
|
||||||
{
|
}, [ roomName, roomOwner, roomTags ]);
|
||||||
updated = true;
|
|
||||||
setRoomOwner(parser.data.ownerName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(roomTags !== parser.data.tags)
|
useEffect(() =>
|
||||||
{
|
|
||||||
updated = true;
|
|
||||||
setRoomTags(parser.data.tags);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(updated)
|
|
||||||
{
|
{
|
||||||
setRoomInfoOpacity(true);
|
setRoomInfoOpacity(true);
|
||||||
setRoomInfoDisplay(true);
|
setRoomInfoDisplay(true);
|
||||||
|
|
||||||
setTimeout(() =>
|
let timeoutDisplay = null;
|
||||||
|
|
||||||
|
const timeoutOpacity = setTimeout(() =>
|
||||||
{
|
{
|
||||||
setRoomInfoOpacity(false);
|
setRoomInfoOpacity(false);
|
||||||
|
|
||||||
setTimeout(() => setRoomInfoDisplay(false), 1000);
|
timeoutDisplay = setTimeout(() => setRoomInfoDisplay(false), 1000);
|
||||||
}, 3000);
|
}, 3000);
|
||||||
}
|
|
||||||
|
return () =>
|
||||||
|
{
|
||||||
|
clearTimeout(timeoutOpacity);
|
||||||
|
clearTimeout(timeoutDisplay);
|
||||||
|
};
|
||||||
}, [ roomName, roomOwner, roomTags ]);
|
}, [ roomName, roomOwner, roomTags ]);
|
||||||
|
|
||||||
CreateMessageHook(GetGuestRoomResultEvent, onGetGuestRoomResultEvent);
|
CreateMessageHook(GetGuestRoomResultEvent, onGetGuestRoomResultEvent);
|
||||||
|
Loading…
Reference in New Issue
Block a user