mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-23 14:40:50 +01:00
Fix respect counter in avatar info
This commit is contained in:
parent
1162469122
commit
2e44b5e693
@ -1,6 +1,6 @@
|
|||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import { RoomControllerLevel, RoomObjectCategory, RoomObjectVariable } from '@nitrots/nitro-renderer';
|
import { RoomControllerLevel, RoomObjectCategory, RoomObjectVariable } from '@nitrots/nitro-renderer';
|
||||||
import { FC, useEffect, useMemo, useState } from 'react';
|
import { FC, useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import { GetOwnRoomObject, GetUserProfile, LocalizeText, RoomWidgetMessage, RoomWidgetUpdateInfostandUserEvent, RoomWidgetUserActionMessage } from '../../../../api';
|
import { GetOwnRoomObject, GetUserProfile, LocalizeText, RoomWidgetMessage, RoomWidgetUpdateInfostandUserEvent, RoomWidgetUserActionMessage } from '../../../../api';
|
||||||
import { Base, Flex } from '../../../../common';
|
import { Base, Flex } from '../../../../common';
|
||||||
import { BatchUpdates } from '../../../../hooks';
|
import { BatchUpdates } from '../../../../hooks';
|
||||||
@ -61,7 +61,7 @@ export const AvatarInfoWidgetAvatarView: FC<AvatarInfoWidgetAvatarViewProps> = p
|
|||||||
return flag;
|
return flag;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const processAction = (name: string) =>
|
const processAction = useCallback((name: string) =>
|
||||||
{
|
{
|
||||||
let messageType: string = null;
|
let messageType: string = null;
|
||||||
let message: RoomWidgetMessage = null;
|
let message: RoomWidgetMessage = null;
|
||||||
@ -114,20 +114,16 @@ export const AvatarInfoWidgetAvatarView: FC<AvatarInfoWidgetAvatarViewProps> = p
|
|||||||
hideMenu = false;
|
hideMenu = false;
|
||||||
setMode(MODE_RELATIONSHIP);
|
setMode(MODE_RELATIONSHIP);
|
||||||
break;
|
break;
|
||||||
case 'respect':
|
case 'respect': {
|
||||||
let newRespectsLeft = 0;
|
let newRespectsLeft = (respectsLeft - 1);
|
||||||
|
|
||||||
setRespectsLeft(prevValue =>
|
setRespectsLeft(newRespectsLeft);
|
||||||
{
|
|
||||||
newRespectsLeft = (prevValue - 1);
|
|
||||||
|
|
||||||
return newRespectsLeft;
|
|
||||||
});
|
|
||||||
|
|
||||||
messageType = RoomWidgetUserActionMessage.RESPECT_USER;
|
messageType = RoomWidgetUserActionMessage.RESPECT_USER;
|
||||||
|
|
||||||
if(newRespectsLeft > 0) hideMenu = false;
|
if(newRespectsLeft > 0) hideMenu = false;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 'ignore':
|
case 'ignore':
|
||||||
messageType = RoomWidgetUserActionMessage.IGNORE_USER;
|
messageType = RoomWidgetUserActionMessage.IGNORE_USER;
|
||||||
break;
|
break;
|
||||||
@ -208,7 +204,7 @@ export const AvatarInfoWidgetAvatarView: FC<AvatarInfoWidgetAvatarViewProps> = p
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(hideMenu) close();
|
if(hideMenu) close();
|
||||||
}
|
}, [ userData, respectsLeft, widgetHandler, close, ]);
|
||||||
|
|
||||||
useEffect(() =>
|
useEffect(() =>
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user