mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-26 23:50:52 +01:00
Group updates
This commit is contained in:
parent
820a147120
commit
01e78e8f38
@ -1,9 +1,9 @@
|
|||||||
import { ContextMenuEnum, FurnitureGroupInfoComposer, GroupFurniContextMenuInfoMessageParser, RoomEngineTriggerWidgetEvent, RoomObjectCategory, RoomObjectVariable } from '@nitrots/nitro-renderer';
|
import { ContextMenuEnum, GroupFurniContextMenuInfoMessageParser, RoomEngineTriggerWidgetEvent, RoomObjectCategory } from '@nitrots/nitro-renderer';
|
||||||
import { GroupFurniContextMenuInfoMessageEvent } from '@nitrots/nitro-renderer/src/nitro/communication/messages/incoming/room/furniture/GroupFurniContextMenuInfoMessageEvent';
|
import { GroupFurniContextMenuInfoMessageEvent } from '@nitrots/nitro-renderer/src/nitro/communication/messages/incoming/room/furniture/GroupFurniContextMenuInfoMessageEvent';
|
||||||
import { FC, useCallback, useState } from 'react';
|
import { FC, useCallback, useState } from 'react';
|
||||||
import { GetRoomEngine, IsOwnerOfFurniture, LocalizeText, RoomWidgetFurniActionMessage, TryVisitRoom } from '../../../../../api';
|
import { GetRoomEngine, IsOwnerOfFurniture, LocalizeText, RoomWidgetFurniActionMessage, TryVisitRoom } from '../../../../../api';
|
||||||
import { TryJoinGroup } from '../../../../../api/groups/TryJoinGroup';
|
import { TryJoinGroup } from '../../../../../api/groups/TryJoinGroup';
|
||||||
import { CreateMessageHook, SendMessageHook } from '../../../../../hooks';
|
import { CreateMessageHook } from '../../../../../hooks';
|
||||||
import { useRoomEngineEvent } from '../../../../../hooks/events';
|
import { useRoomEngineEvent } from '../../../../../hooks/events';
|
||||||
import { useRoomContext } from '../../../context/RoomContext';
|
import { useRoomContext } from '../../../context/RoomContext';
|
||||||
import { ContextMenuView } from '../../context-menu/ContextMenuView';
|
import { ContextMenuView } from '../../context-menu/ContextMenuView';
|
||||||
@ -14,6 +14,7 @@ import { PurchasableClothingConfirmView } from './views/purchaseable-clothing/Pu
|
|||||||
|
|
||||||
const MONSTERPLANT_SEED_CONFIRMATION: string = 'MONSTERPLANT_SEED_CONFIRMATION';
|
const MONSTERPLANT_SEED_CONFIRMATION: string = 'MONSTERPLANT_SEED_CONFIRMATION';
|
||||||
const PURCHASABLE_CLOTHING_CONFIRMATION: string = 'PURCHASABLE_CLOTHING_CONFIRMATION';
|
const PURCHASABLE_CLOTHING_CONFIRMATION: string = 'PURCHASABLE_CLOTHING_CONFIRMATION';
|
||||||
|
const GROUP_FURNITURE: string = 'GROUP_FURNITURE';
|
||||||
|
|
||||||
export const FurnitureContextMenuView: FC<{}> = props =>
|
export const FurnitureContextMenuView: FC<{}> = props =>
|
||||||
{
|
{
|
||||||
@ -22,13 +23,15 @@ export const FurnitureContextMenuView: FC<{}> = props =>
|
|||||||
const [ confirmMode, setConfirmMode ] = useState<string>(null);
|
const [ confirmMode, setConfirmMode ] = useState<string>(null);
|
||||||
const [ confirmingObjectId, setConfirmingObjectId ] = useState(-1);
|
const [ confirmingObjectId, setConfirmingObjectId ] = useState(-1);
|
||||||
const [ groupData, setGroupData ] = useState<GroupFurniContextMenuInfoMessageParser>(null);
|
const [ groupData, setGroupData ] = useState<GroupFurniContextMenuInfoMessageParser>(null);
|
||||||
const [ isGroupMember, setIsGroupMember ] = useState<boolean>(false);
|
const [ isGroupMember, setIsGroupMember ] = useState(false);
|
||||||
|
|
||||||
const { roomSession = null, widgetHandler = null } = useRoomContext();
|
const { roomSession = null, widgetHandler = null } = useRoomContext();
|
||||||
|
|
||||||
const close = useCallback(() =>
|
const close = useCallback(() =>
|
||||||
{
|
{
|
||||||
setObjectId(-1);
|
setObjectId(-1);
|
||||||
|
setGroupData(null);
|
||||||
|
setIsGroupMember(false);
|
||||||
setMode(null);
|
setMode(null);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@ -77,9 +80,6 @@ export const FurnitureContextMenuView: FC<{}> = props =>
|
|||||||
case ContextMenuEnum.PURCHASABLE_CLOTHING:
|
case ContextMenuEnum.PURCHASABLE_CLOTHING:
|
||||||
if(IsOwnerOfFurniture(object)) setMode(ContextMenuEnum.PURCHASABLE_CLOTHING);
|
if(IsOwnerOfFurniture(object)) setMode(ContextMenuEnum.PURCHASABLE_CLOTHING);
|
||||||
return;
|
return;
|
||||||
case ContextMenuEnum.GROUP_FURNITURE:
|
|
||||||
SendMessageHook(new FurnitureGroupInfoComposer(object.id, object.model.getValue<number>(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_GUILD_ID)));
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -97,11 +97,11 @@ export const FurnitureContextMenuView: FC<{}> = props =>
|
|||||||
const onGroupFurniContextMenuInfoMessageEvent = useCallback((event: GroupFurniContextMenuInfoMessageEvent) =>
|
const onGroupFurniContextMenuInfoMessageEvent = useCallback((event: GroupFurniContextMenuInfoMessageEvent) =>
|
||||||
{
|
{
|
||||||
const parser = event.getParser();
|
const parser = event.getParser();
|
||||||
|
|
||||||
setGroupData(null);
|
setObjectId(parser.objectId);
|
||||||
setGroupData(parser);
|
setGroupData(parser);
|
||||||
setIsGroupMember(parser.userIsMember);
|
setIsGroupMember(parser.userIsMember);
|
||||||
setMode(ContextMenuEnum.GROUP_FURNITURE);
|
setMode(GROUP_FURNITURE);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
CreateMessageHook(GroupFurniContextMenuInfoMessageEvent, onGroupFurniContextMenuInfoMessageEvent);
|
CreateMessageHook(GroupFurniContextMenuInfoMessageEvent, onGroupFurniContextMenuInfoMessageEvent);
|
||||||
@ -181,7 +181,7 @@ export const FurnitureContextMenuView: FC<{}> = props =>
|
|||||||
{ LocalizeText('widget.generic_usable.button.use') }
|
{ LocalizeText('widget.generic_usable.button.use') }
|
||||||
</ContextMenuListItemView>
|
</ContextMenuListItemView>
|
||||||
</> }
|
</> }
|
||||||
{ (mode === ContextMenuEnum.GROUP_FURNITURE) && groupData &&
|
{ (mode === GROUP_FURNITURE) && groupData &&
|
||||||
<>
|
<>
|
||||||
<ContextMenuHeaderView>
|
<ContextMenuHeaderView>
|
||||||
{ groupData.guildName }
|
{ groupData.guildName }
|
||||||
|
Loading…
Reference in New Issue
Block a user