Fix respect counter in avatar info

This commit is contained in:
Bill 2022-03-30 13:22:11 -04:00
parent 1162469122
commit 2e44b5e693

View File

@ -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(() =>
{ {