Update packet handlers

This commit is contained in:
Bill 2022-07-28 02:10:06 -04:00
parent 909f996dd8
commit 42cdd0ae4f
31 changed files with 185 additions and 356 deletions

View File

@ -1,5 +1,5 @@
import { CameraPublishStatusMessageEvent, CameraPurchaseOKMessageEvent, CameraStorageUrlMessageEvent, PublishPhotoMessageComposer, PurchasePhotoMessageComposer } from '@nitrots/nitro-renderer';
import { FC, useCallback, useEffect, useMemo, useState } from 'react';
import { FC, useEffect, useMemo, useState } from 'react';
import { CreateLinkEvent, GetConfiguration, GetRoomEngine, LocalizeText, SendMessageComposer } from '../../../api';
import { Button, Column, Flex, LayoutCurrencyIcon, LayoutImage, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../common';
import { useMessageEvent } from '../../../hooks';
@ -24,15 +24,13 @@ export const CameraWidgetCheckoutView: FC<CameraWidgetCheckoutViewProps> = props
const publishDisabled = useMemo(() => GetConfiguration<boolean>('camera.publish.disabled', false), []);
const onCameraPurchaseOKMessageEvent = useCallback((event: CameraPurchaseOKMessageEvent) =>
useMessageEvent<CameraPurchaseOKMessageEvent>(CameraPurchaseOKMessageEvent, event =>
{
setPicturesBought(value => (value + 1));
setIsWaiting(false);
}, []);
});
useMessageEvent(CameraPurchaseOKMessageEvent, onCameraPurchaseOKMessageEvent);
const onCameraPublishStatusMessageEvent = useCallback((event: CameraPublishStatusMessageEvent) =>
useMessageEvent<CameraPublishStatusMessageEvent>(CameraPublishStatusMessageEvent, event =>
{
const parser = event.getParser();
@ -40,18 +38,14 @@ export const CameraWidgetCheckoutView: FC<CameraWidgetCheckoutViewProps> = props
setPublishCooldown(parser.secondsToWait);
setWasPicturePublished(parser.ok);
setIsWaiting(false);
}, []);
});
useMessageEvent(CameraPublishStatusMessageEvent, onCameraPublishStatusMessageEvent);
const onCameraStorageUrlMessageEvent = useCallback((event: CameraStorageUrlMessageEvent) =>
useMessageEvent<CameraStorageUrlMessageEvent>(CameraStorageUrlMessageEvent, event =>
{
const parser = event.getParser();
setPictureUrl(GetConfiguration<string>('camera.url') + '/' + parser.url);
}, []);
useMessageEvent(CameraStorageUrlMessageEvent, onCameraStorageUrlMessageEvent);
});
const processAction = (type: string, value: string | number = null) =>
{

View File

@ -10,18 +10,16 @@ export const CampaignView: FC<{}> = props =>
const [ lastOpenAttempt, setLastOpenAttempt ] = useState<number>(-1);
const [ receivedProducts, setReceivedProducts ] = useState<Map<number, CalendarItem>>(new Map());
const [ isCalendarOpen, setCalendarOpen ] = useState(false);
const onCampaignCalendarDataMessageEvent = useCallback((event: CampaignCalendarDataMessageEvent) =>
useMessageEvent<CampaignCalendarDataMessageEvent>(CampaignCalendarDataMessageEvent, event =>
{
const parser = event.getParser();
if(!parser) return;
setCalendarData(parser.calendarData);
}, []);
});
useMessageEvent(CampaignCalendarDataMessageEvent, onCampaignCalendarDataMessageEvent);
const onCampaignCalendarDoorOpenedMessageEvent = useCallback((event: CampaignCalendarDoorOpenedMessageEvent) =>
useMessageEvent<CampaignCalendarDoorOpenedMessageEvent>(CampaignCalendarDoorOpenedMessageEvent, event =>
{
const parser = event.getParser();
@ -49,9 +47,7 @@ export const CampaignView: FC<{}> = props =>
}
setLastOpenAttempt(-1);
}, [ lastOpenAttempt ]);
useMessageEvent(CampaignCalendarDoorOpenedMessageEvent, onCampaignCalendarDoorOpenedMessageEvent);
});
const openPackage = useCallback((id: number, asStaff = false) =>
{

View File

@ -113,12 +113,7 @@ export const CatalogGiftView: FC<{}> = props =>
}
}, [ extraData, maxBoxIndex, maxRibbonIndex, message, offerId, pageId, receiverName, selectedBoxIndex, selectedColorId, selectedRibbonIndex, showMyFace ]);
const onGiftReceiverNotFoundEvent = useCallback(() =>
{
setReceiverNotFound(true);
}, []);
useMessageEvent(GiftReceiverNotFoundEvent, onGiftReceiverNotFoundEvent);
useMessageEvent<GiftReceiverNotFoundEvent>(GiftReceiverNotFoundEvent, event => setReceiverNotFound(true));
useEffect(() =>
{

View File

@ -1,6 +1,6 @@
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { RedeemVoucherMessageComposer, VoucherRedeemErrorMessageEvent, VoucherRedeemOkMessageEvent } from '@nitrots/nitro-renderer';
import { FC, useCallback, useState } from 'react';
import { FC, useState } from 'react';
import { LocalizeText, SendMessageComposer } from '../../../../../api';
import { Button, Flex } from '../../../../../common';
import { useMessageEvent, useNotification } from '../../../../../hooks';
@ -26,7 +26,7 @@ export const CatalogRedeemVoucherView: FC<CatalogRedeemVoucherViewProps> = props
setIsWaiting(true);
}
const onVoucherRedeemOkMessageEvent = useCallback((event: VoucherRedeemOkMessageEvent) =>
useMessageEvent<VoucherRedeemOkMessageEvent>(VoucherRedeemOkMessageEvent, event =>
{
const parser = event.getParser();
@ -38,20 +38,16 @@ export const CatalogRedeemVoucherView: FC<CatalogRedeemVoucherViewProps> = props
setIsWaiting(false);
setVoucher('');
}, [ simpleAlert ]);
});
useMessageEvent(VoucherRedeemOkMessageEvent, onVoucherRedeemOkMessageEvent);
const onVoucherRedeemErrorMessageEvent = useCallback((event: VoucherRedeemErrorMessageEvent) =>
useMessageEvent<VoucherRedeemErrorMessageEvent>(VoucherRedeemErrorMessageEvent, event =>
{
const parser = event.getParser();
simpleAlert(LocalizeText(`catalog.alert.voucherredeem.error.description.${ parser.errorCode }`), null, null, null, LocalizeText('catalog.alert.voucherredeem.error.title'));
setIsWaiting(false);
}, [ simpleAlert ]);
useMessageEvent(VoucherRedeemErrorMessageEvent, onVoucherRedeemErrorMessageEvent);
});
return (
<Flex gap={ 1 }>

View File

@ -16,16 +16,14 @@ export const CatalogLayoutRoomAdsView: FC<CatalogLayoutProps> = props =>
const [ categoryId, setCategoryId ] = useState<number>(1);
const [ categories, setCategories ] = useState<INavigatorCategory[]>(null);
const onRoomAdPurchaseInfoEvent = (event: RoomAdPurchaseInfoEvent) =>
useMessageEvent<RoomAdPurchaseInfoEvent>(RoomAdPurchaseInfoEvent, event =>
{
const parser = event.getParser();
if(!parser) return;
setAvailableRooms(parser.rooms);
}
useMessageEvent(RoomAdPurchaseInfoEvent, onRoomAdPurchaseInfoEvent);
});
const purchaseAd = useCallback(() =>
{
@ -39,15 +37,12 @@ export const CatalogLayoutRoomAdsView: FC<CatalogLayoutProps> = props =>
SendMessageComposer(new PurchaseRoomAdMessageComposer(pageId, offerId, flatId, name, extended, desc, catId))
}, [ categoryId, eventDesc, eventName, extended, page.offers, page.pageId, roomId ]);
const onUserEventCatsEvent = (event: UserEventCatsEvent) =>
useMessageEvent<UserEventCatsEvent>(UserEventCatsEvent, event =>
{
const parser = event.getParser();
setCategories(parser.categories);
}
useMessageEvent(UserEventCatsEvent, onUserEventCatsEvent);
});
useEffect(() =>
{

View File

@ -14,7 +14,7 @@ export const CatalogLayoutMarketplaceOwnItemsView: FC<CatalogLayoutProps> = prop
const [ offers, setOffers ] = useState<MarketplaceOfferData[]>([]);
const { simpleAlert = null } = useNotification();
const onMarketPlaceOwnOffersEvent = useCallback((event: MarketplaceOwnOffersEvent) =>
useMessageEvent<MarketplaceOwnOffersEvent>(MarketplaceOwnOffersEvent, event =>
{
const parser = event.getParser();
@ -30,12 +30,10 @@ export const CatalogLayoutMarketplaceOwnItemsView: FC<CatalogLayoutProps> = prop
});
setCreditsWaiting(parser.creditsWaiting);
setOffers(offers);
}, []);
setOffers(offers);
});
useMessageEvent(MarketplaceOwnOffersEvent, onMarketPlaceOwnOffersEvent);
const onMarketplaceCancelOfferResultEvent = useCallback((event:MarketplaceCancelOfferResultEvent) =>
useMessageEvent<MarketplaceCancelOfferResultEvent>(MarketplaceCancelOfferResultEvent, event =>
{
const parser = event.getParser();
@ -49,9 +47,7 @@ export const CatalogLayoutMarketplaceOwnItemsView: FC<CatalogLayoutProps> = prop
}
setOffers(prevValue => prevValue.filter(value => (value.offerId !== parser.offerId)));
}, [ simpleAlert ]);
useMessageEvent(MarketplaceCancelOfferResultEvent, onMarketplaceCancelOfferResultEvent);
});
const soldOffers = useMemo(() =>
{

View File

@ -64,7 +64,7 @@ export const CatalogLayoutMarketplacePublicItemsView: FC<CatalogLayoutMarketplac
null, null, null, LocalizeText('catalog.marketplace.confirm_title'));
}, [ getCurrencyAmount, simpleAlert, showConfirm ]);
const onMarketPlaceOffersEvent = useCallback( (event: MarketPlaceOffersEvent) =>
useMessageEvent<MarketPlaceOffersEvent>(MarketPlaceOffersEvent, event =>
{
const parser = event.getParser();
@ -80,9 +80,9 @@ export const CatalogLayoutMarketplacePublicItemsView: FC<CatalogLayoutMarketplac
setTotalItemsFound(parser.totalItemsFound);
setOffers(latestOffers);
}, []);
});
const onMarketplaceBuyOfferResultEvent = useCallback( (event: MarketplaceBuyOfferResultEvent) =>
useMessageEvent<MarketplaceBuyOfferResultEvent>(MarketplaceBuyOfferResultEvent, event =>
{
const parser = event.getParser();
@ -133,10 +133,7 @@ export const CatalogLayoutMarketplacePublicItemsView: FC<CatalogLayoutMarketplac
simpleAlert(LocalizeText('catalog.alert.notenough.credits.description'), NotificationAlertType.DEFAULT, null, null, LocalizeText('catalog.alert.notenough.title'));
break;
}
}, [ lastSearch, requestOffers, simpleAlert, showConfirm ]);
useMessageEvent(MarketPlaceOffersEvent, onMarketPlaceOffersEvent);
useMessageEvent(MarketplaceBuyOfferResultEvent, onMarketplaceBuyOfferResultEvent);
});
return (
<>

View File

@ -104,7 +104,7 @@ export const CatalogLayoutPetView: FC<CatalogLayoutProps> = props =>
}
}, [ page, currentOffer, petName, petPurchaseString, approvalResult ]);
const onApproveNameMessageEvent = useCallback((event: ApproveNameMessageEvent) =>
useMessageEvent<ApproveNameMessageEvent>(ApproveNameMessageEvent, event =>
{
const parser = event.getParser();
@ -112,9 +112,7 @@ export const CatalogLayoutPetView: FC<CatalogLayoutProps> = props =>
if(parser.result === 0) purchasePet();
else DispatchUiEvent(new CatalogPurchaseFailureEvent(-1));
}, [ purchasePet ]);
useMessageEvent(ApproveNameMessageEvent, onApproveNameMessageEvent);
});
useEffect(() =>
{

View File

@ -1,5 +1,5 @@
import { FloorHeightMapEvent, ILinkEventTracker, NitroPoint, RoomEngineEvent, RoomVisualizationSettingsEvent, UpdateFloorPropertiesMessageComposer } from '@nitrots/nitro-renderer';
import { FC, useCallback, useEffect, useState } from 'react';
import { FC, useEffect, useState } from 'react';
import { AddEventLinkTracker, LocalizeText, RemoveLinkEventTracker, SendMessageComposer } from '../../api';
import { Button, ButtonGroup, Flex, NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../common';
import { useMessageEvent, useRoomEngineEvent } from '../../hooks';
@ -54,14 +54,9 @@ export const FloorplanEditorView: FC<{}> = props =>
FloorplanEditor.instance.renderTiles();
}
const onRoomEngineEvent = useCallback((event: RoomEngineEvent) =>
{
setIsVisible(false);
}, []);
useRoomEngineEvent<RoomEngineEvent>(RoomEngineEvent.DISPOSED, event => setIsVisible(false));
useRoomEngineEvent(RoomEngineEvent.DISPOSED, onRoomEngineEvent);
const onFloorHeightMapEvent = useCallback((event: FloorHeightMapEvent) =>
useMessageEvent<FloorHeightMapEvent>(FloorHeightMapEvent, event =>
{
const parser = event.getParser();
@ -83,11 +78,9 @@ export const FloorplanEditorView: FC<{}> = props =>
return newValue;
});
}, []);
});
useMessageEvent(FloorHeightMapEvent, onFloorHeightMapEvent);
const onRoomVisualizationSettingsEvent = useCallback((event: RoomVisualizationSettingsEvent) =>
useMessageEvent<RoomVisualizationSettingsEvent>(RoomVisualizationSettingsEvent, event =>
{
const parser = event.getParser();
@ -110,9 +103,7 @@ export const FloorplanEditorView: FC<{}> = props =>
return newValue;
});
}, []);
useMessageEvent(RoomVisualizationSettingsEvent, onRoomVisualizationSettingsEvent);
});
useEffect(() =>
{

View File

@ -1,6 +1,6 @@
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { GetOccupiedTilesMessageComposer, GetRoomEntryTileMessageComposer, NitroPoint, RoomEntryTileMessageEvent, RoomOccupiedTilesMessageEvent } from '@nitrots/nitro-renderer';
import { FC, useCallback, useEffect, useRef, useState } from 'react';
import { FC, useEffect, useRef, useState } from 'react';
import { SendMessageComposer } from '../../../api';
import { Base, Button, Column, ColumnProps, Flex, Grid } from '../../../common';
import { useMessageEvent } from '../../../hooks';
@ -15,7 +15,7 @@ export const FloorplanCanvasView: FC<ColumnProps> = props =>
const { originalFloorplanSettings = null, setOriginalFloorplanSettings = null, setVisualizationSettings = null } = useFloorplanEditorContext();
const elementRef = useRef<HTMLDivElement>(null);
const onRoomOccupiedTilesMessageEvent = useCallback((event: RoomOccupiedTilesMessageEvent) =>
useMessageEvent<RoomOccupiedTilesMessageEvent>(RoomOccupiedTilesMessageEvent, event =>
{
const parser = event.getParser();
@ -33,11 +33,9 @@ export const FloorplanCanvasView: FC<ColumnProps> = props =>
setOccupiedTilesReceived(true);
elementRef.current.scrollTo((FloorplanEditor.instance.view.width / 3), 0);
}, [ setOriginalFloorplanSettings ]);
});
useMessageEvent(RoomOccupiedTilesMessageEvent, onRoomOccupiedTilesMessageEvent);
const onRoomEntryTileMessageEvent = useCallback((event: RoomEntryTileMessageEvent) =>
useMessageEvent<RoomEntryTileMessageEvent>(RoomEntryTileMessageEvent, event =>
{
const parser = event.getParser();
@ -63,9 +61,7 @@ export const FloorplanCanvasView: FC<ColumnProps> = props =>
FloorplanEditor.instance.doorLocation = new NitroPoint(parser.x, parser.y);
setEntryTileReceived(true);
}, [ setOriginalFloorplanSettings, setVisualizationSettings ]);
useMessageEvent(RoomEntryTileMessageEvent, onRoomEntryTileMessageEvent);
});
const onClickArrowButton = (scrollDirection: string) =>
{

View File

@ -1,5 +1,5 @@
import { HabboSearchComposer, HabboSearchResultData, HabboSearchResultEvent } from '@nitrots/nitro-renderer';
import { FC, useCallback, useEffect, useState } from 'react';
import { FC, useEffect, useState } from 'react';
import { LocalizeText, OpenMessengerChat, SendMessageComposer } from '../../../../api';
import { Base, Column, Flex, NitroCardAccordionItemView, NitroCardAccordionSetView, NitroCardAccordionSetViewProps, Text, UserProfileIconView } from '../../../../common';
import { useFriends, useMessageEvent } from '../../../../hooks';
@ -17,15 +17,13 @@ export const FriendsSearchView: FC<FriendsSearchViewProps> = props =>
const [ otherResults, setOtherResults ] = useState<HabboSearchResultData[]>(null);
const { canRequestFriend = null, requestFriend = null } = useFriends();
const onHabboSearchResultEvent = useCallback((event: HabboSearchResultEvent) =>
useMessageEvent<HabboSearchResultEvent>(HabboSearchResultEvent, event =>
{
const parser = event.getParser();
setFriendResults(parser.friends);
setOtherResults(parser.others);
}, []);
useMessageEvent(HabboSearchResultEvent, onHabboSearchResultEvent);
});
useEffect(() =>
{

View File

@ -1,5 +1,5 @@
import { GroupBuyComposer, GroupBuyDataComposer, GroupBuyDataEvent } from '@nitrots/nitro-renderer';
import { FC, useCallback, useEffect, useState } from 'react';
import { FC, useEffect, useState } from 'react';
import { HasHabboClub, IGroupData, LocalizeText, SendMessageComposer } from '../../../api';
import { Base, Button, Column, Flex, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../common';
import { useMessageEvent } from '../../../hooks';
@ -85,7 +85,7 @@ export const GroupCreatorView: FC<GroupCreatorViewProps> = props =>
setCurrentTab(value => (value === 4 ? value : value + 1));
}
const onGroupBuyDataEvent = useCallback((event: GroupBuyDataEvent) =>
useMessageEvent<GroupBuyDataEvent>(GroupBuyDataEvent, event =>
{
const parser = event.getParser();
@ -95,9 +95,7 @@ export const GroupCreatorView: FC<GroupCreatorViewProps> = props =>
setAvailableRooms(rooms);
setPurchaseCost(parser.groupCost);
}, []);
useMessageEvent(GroupBuyDataEvent, onGroupBuyDataEvent);
});
useEffect(() =>
{

View File

@ -1,5 +1,5 @@
import { GroupInformationEvent, GroupInformationParser } from '@nitrots/nitro-renderer';
import { FC, useCallback, useState } from 'react';
import { FC, useState } from 'react';
import { LocalizeText } from '../../../api';
import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../common';
import { useMessageEvent } from '../../../hooks';
@ -9,14 +9,12 @@ export const GroupInformationStandaloneView: FC<{}> = props =>
{
const [ groupInformation, setGroupInformation ] = useState<GroupInformationParser>(null);
const onGroupInformationEvent = useCallback((event: GroupInformationEvent) =>
useMessageEvent<GroupInformationEvent>(GroupInformationEvent, event =>
{
const parser = event.getParser();
if((groupInformation && (groupInformation.id === parser.id)) || parser.flag) setGroupInformation(parser);
}, [ groupInformation ]);
useMessageEvent(GroupInformationEvent, onGroupInformationEvent);
});
if(!groupInformation) return null;

View File

@ -73,18 +73,16 @@ export const GroupMembersView: FC<{}> = props =>
SendMessageComposer(new GroupConfirmRemoveMemberComposer(membersData.groupId, member.id));
}
const onGroupMembersEvent = useCallback((event: GroupMembersEvent) =>
useMessageEvent<GroupMembersEvent>(GroupMembersEvent, event =>
{
const parser = event.getParser();
setMembersData(parser);
setLevelId(parser.level);
setTotalPages(Math.ceil(parser.totalMembersCount / parser.pageSize));
}, []);
});
useMessageEvent(GroupMembersEvent, onGroupMembersEvent);
const onGroupConfirmMemberRemoveEvent = useCallback((event: GroupConfirmMemberRemoveEvent) =>
useMessageEvent<GroupConfirmMemberRemoveEvent>(GroupConfirmMemberRemoveEvent, event =>
{
const parser = event.getParser();
@ -96,9 +94,7 @@ export const GroupMembersView: FC<{}> = props =>
}, null);
setRemovingMemberName(null);
}, [ membersData, removingMemberName, refreshMembers, showConfirm ]);
useMessageEvent(GroupConfirmMemberRemoveEvent, onGroupConfirmMemberRemoveEvent);
});
useEffect(() =>
{

View File

@ -1,6 +1,6 @@
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { DesktopViewEvent, GetGuestRoomResultEvent, GroupInformationComposer, GroupInformationEvent, GroupInformationParser, GroupRemoveMemberComposer, HabboGroupDeactivatedMessageEvent, RoomEntryInfoMessageEvent } from '@nitrots/nitro-renderer';
import { FC, useCallback, useState } from 'react';
import { FC, useState } from 'react';
import { GetGroupInformation, GetGroupManager, GetSessionDataManager, GroupMembershipType, GroupType, LocalizeText, SendMessageComposer, TryJoinGroup } from '../../../api';
import { Base, Button, Column, Flex, LayoutBadgeImageView, Text } from '../../../common';
import { useMessageEvent, useNotification } from '../../../hooks';
@ -12,23 +12,19 @@ export const GroupRoomInformationView: FC<{}> = props =>
const [ isOpen, setIsOpen ] = useState<boolean>(true);
const { showConfirm = null } = useNotification();
const onDesktopViewEvent = useCallback((event: DesktopViewEvent) =>
useMessageEvent<DesktopViewEvent>(DesktopViewEvent, event =>
{
setExpectedGroupId(0);
setGroupInformation(null);
}, []);
});
useMessageEvent(DesktopViewEvent, onDesktopViewEvent);
const onRoomEntryInfoMessageEvent = useCallback((event: RoomEntryInfoMessageEvent) =>
useMessageEvent<RoomEntryInfoMessageEvent>(RoomEntryInfoMessageEvent, event =>
{
setExpectedGroupId(0);
setGroupInformation(null);
}, []);
});
useMessageEvent(RoomEntryInfoMessageEvent, onRoomEntryInfoMessageEvent);
const onGetGuestRoomResultEvent = useCallback((event: GetGuestRoomResultEvent) =>
useMessageEvent<GetGuestRoomResultEvent>(GetGuestRoomResultEvent, event =>
{
const parser = event.getParser();
@ -44,11 +40,9 @@ export const GroupRoomInformationView: FC<{}> = props =>
setExpectedGroupId(0);
setGroupInformation(null);
}
}, []);
});
useMessageEvent(GetGuestRoomResultEvent, onGetGuestRoomResultEvent);
const onHabboGroupDeactivatedMessageEvent = useCallback((event: HabboGroupDeactivatedMessageEvent) =>
useMessageEvent<HabboGroupDeactivatedMessageEvent>(HabboGroupDeactivatedMessageEvent, event =>
{
const parser = event.getParser();
@ -56,20 +50,16 @@ export const GroupRoomInformationView: FC<{}> = props =>
setExpectedGroupId(0);
setGroupInformation(null);
}, [ expectedGroupId, groupInformation ]);
});
useMessageEvent(HabboGroupDeactivatedMessageEvent, onHabboGroupDeactivatedMessageEvent);
const onGroupInformationEvent = useCallback((event: GroupInformationEvent) =>
useMessageEvent<GroupInformationEvent>(GroupInformationEvent, event =>
{
const parser = event.getParser();
if(parser.id !== expectedGroupId) return;
setGroupInformation(parser);
}, [ expectedGroupId ]);
useMessageEvent(GroupInformationEvent, onGroupInformationEvent);
});
const leaveGroup = () =>
{

View File

@ -107,7 +107,7 @@ export const GuideToolView: FC<{}> = props =>
useUiEvent(GuideToolEvent.TOGGLE_GUIDE_TOOL, onGuideToolEvent);
useUiEvent(GuideToolEvent.CREATE_HELP_REQUEST, onGuideToolEvent);
const onPerkAllowancesMessageEvent = useCallback((event: PerkAllowancesMessageEvent) =>
useMessageEvent<PerkAllowancesMessageEvent>(PerkAllowancesMessageEvent, event =>
{
const parser = event.getParser();
@ -116,11 +116,9 @@ export const GuideToolView: FC<{}> = props =>
setIsOnDuty(false);
SendMessageComposer(new GuideSessionOnDutyUpdateMessageComposer(false, false, false, false));
}
}, [ isOnDuty, setIsOnDuty ]);
});
useMessageEvent(PerkAllowancesMessageEvent, onPerkAllowancesMessageEvent);
const onGuideOnDutyStatusMessageEvent = useCallback((event: GuideOnDutyStatusMessageEvent) =>
useMessageEvent<GuideOnDutyStatusMessageEvent>(GuideOnDutyStatusMessageEvent, event =>
{
const parser = event.getParser();
@ -128,11 +126,9 @@ export const GuideToolView: FC<{}> = props =>
setGuidesOnDuty(parser.guidesOnDuty);
setHelpersOnDuty(parser.helpersOnDuty);
setGuardiansOnDuty(parser.guardiansOnDuty);
}, [ setIsOnDuty, setHelpersOnDuty, setGuidesOnDuty, setGuardiansOnDuty ]);
});
useMessageEvent(GuideOnDutyStatusMessageEvent, onGuideOnDutyStatusMessageEvent);
const onGuideSessionAttachedMessageEvent = useCallback((event: GuideSessionAttachedMessageEvent) =>
useMessageEvent<GuideSessionAttachedMessageEvent>(GuideSessionAttachedMessageEvent, event =>
{
const parser = event.getParser();
@ -142,12 +138,9 @@ export const GuideToolView: FC<{}> = props =>
if(parser.asGuide && isOnDuty) updateSessionState(GuideSessionState.GUIDE_ACCEPT);
if(!parser.asGuide) updateSessionState(GuideSessionState.USER_PENDING);
}, [ isOnDuty, updateSessionState ]);
});
useMessageEvent(GuideSessionAttachedMessageEvent, onGuideSessionAttachedMessageEvent);
const onGuideSessionStartedMessageEvent = useCallback((event: GuideSessionStartedMessageEvent) =>
useMessageEvent<GuideSessionStartedMessageEvent>(GuideSessionStartedMessageEvent, event =>
{
const parser = event.getParser();
@ -165,20 +158,16 @@ export const GuideToolView: FC<{}> = props =>
setOngoingFigure(parser.guideFigure);
updateSessionState(GuideSessionState.USER_ONGOING, parser.guideName);
}
}, [ isOnDuty, updateSessionState ]);
});
useMessageEvent(GuideSessionStartedMessageEvent, onGuideSessionStartedMessageEvent);
const onGuideSessionPartnerIsTypingMessageEvent = useCallback((event: GuideSessionPartnerIsTypingMessageEvent) =>
useMessageEvent<GuideSessionPartnerIsTypingMessageEvent>(GuideSessionPartnerIsTypingMessageEvent, event =>
{
const parser = event.getParser();
setOngoingIsTyping(parser.isTyping);
}, []);
});
useMessageEvent(GuideSessionPartnerIsTypingMessageEvent, onGuideSessionPartnerIsTypingMessageEvent);
const onGuideSessionMessageMessageEvent = useCallback((event: GuideSessionMessageMessageEvent) =>
useMessageEvent<GuideSessionMessageMessageEvent>(GuideSessionMessageMessageEvent, event =>
{
const parser = event.getParser();
@ -194,11 +183,9 @@ export const GuideToolView: FC<{}> = props =>
lastGroup.addChat(new GuideToolMessage(parser.chatMessage));
setOngoingMessageGroups(messageGroups);
}, [ ongoingMessageGroups ]);
});
useMessageEvent(GuideSessionMessageMessageEvent, onGuideSessionMessageMessageEvent);
const onGuideSessionInvitedToGuideRoomMessageEvent = useCallback((event: GuideSessionInvitedToGuideRoomMessageEvent) =>
useMessageEvent<GuideSessionInvitedToGuideRoomMessageEvent>(GuideSessionInvitedToGuideRoomMessageEvent, event =>
{
const parser = event.getParser();
@ -216,11 +203,9 @@ export const GuideToolView: FC<{}> = props =>
lastGroup.addChat(new GuideToolMessage(parser.roomName, parser.roomId));
setOngoingMessageGroups(messageGroups);
}, [ isOnDuty, ongoingMessageGroups, ongoingUserId ]);
});
useMessageEvent(GuideSessionInvitedToGuideRoomMessageEvent, onGuideSessionInvitedToGuideRoomMessageEvent);
const onGuideSessionEndedMessageEvent = useCallback((event: GuideSessionEndedMessageEvent) =>
useMessageEvent<GuideSessionEndedMessageEvent>(GuideSessionEndedMessageEvent, event =>
{
if(isOnDuty)
{
@ -235,11 +220,9 @@ export const GuideToolView: FC<{}> = props =>
{
updateSessionState(GuideSessionState.USER_FEEDBACK);
}
}, [ isOnDuty, updateSessionState ]);
});
useMessageEvent(GuideSessionEndedMessageEvent, onGuideSessionEndedMessageEvent);
const onGuideSessionDetachedMessageEvent = useCallback((event: GuideSessionDetachedMessageEvent) =>
useMessageEvent<GuideSessionDetachedMessageEvent>(GuideSessionDetachedMessageEvent, event =>
{
setOngoingUserId(0);
setOngoingUsername(null);
@ -256,9 +239,7 @@ export const GuideToolView: FC<{}> = props =>
{
updateSessionState(GuideSessionState.USER_THANKS);
}
}, [ isOnDuty, updateSessionState ]);
useMessageEvent(GuideSessionDetachedMessageEvent, onGuideSessionDetachedMessageEvent);
});
useEffect(() =>
{

View File

@ -35,14 +35,12 @@ export const GuideToolOngoingView: FC<GuideToolOngoingViewProps> = props =>
SendMessageComposer(new GuideSessionResolvedMessageComposer());
}, []);
const onGuideSessionRequesterRoomMessageEvent = useCallback((event: GuideSessionRequesterRoomMessageEvent) =>
useMessageEvent<GuideSessionRequesterRoomMessageEvent>(GuideSessionRequesterRoomMessageEvent, event =>
{
const parser = event.getParser();
TryVisitRoom(parser.requesterRoomId);
}, []);
useMessageEvent(GuideSessionRequesterRoomMessageEvent, onGuideSessionRequesterRoomMessageEvent);
});
const sendMessage = useCallback(() =>
{

View File

@ -1,5 +1,5 @@
import { ClubGiftInfoEvent, FriendlyTime, GetClubGiftInfo, ILinkEventTracker, ScrGetKickbackInfoMessageComposer, ScrKickbackData, ScrSendKickbackInfoMessageEvent } from '@nitrots/nitro-renderer';
import { FC, useCallback, useEffect, useState } from 'react';
import { FC, useEffect, useState } from 'react';
import { OverlayTrigger, Popover } from 'react-bootstrap';
import { AddEventLinkTracker, ClubStatus, CreateLinkEvent, GetClubBadge, GetConfiguration, LocalizeText, RemoveLinkEventTracker, SendMessageComposer } from '../../api';
import { Base, Button, Column, Flex, LayoutAvatarImageView, LayoutBadgeImageView, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../common';
@ -44,23 +44,19 @@ export const HcCenterView: FC<{}> = props =>
const getHcPaydayTime = () => (kickbackData.timeUntilPayday < 60) ? LocalizeText('hccenter.special.time.soon') : FriendlyTime.shortFormat(kickbackData.timeUntilPayday * 60);
const getHcPaydayAmount = () => LocalizeText('hccenter.special.sum', [ 'credits' ], [ (kickbackData.creditRewardForStreakBonus + kickbackData.creditRewardForMonthlySpent).toString() ]);
const onClubGiftInfoEvent = useCallback((event: ClubGiftInfoEvent) =>
useMessageEvent<ClubGiftInfoEvent>(ClubGiftInfoEvent, event =>
{
const parser = event.getParser();
setUnclaimedGifts(parser.giftsAvailable);
}, []);
});
useMessageEvent(ClubGiftInfoEvent, onClubGiftInfoEvent);
const onScrSendKickbackInfo = useCallback((event: ScrSendKickbackInfoMessageEvent) =>
useMessageEvent<ScrSendKickbackInfoMessageEvent>(ScrSendKickbackInfoMessageEvent, event =>
{
const parser = event.getParser();
setKickbackData(parser.data);
}, []);
useMessageEvent(ScrSendKickbackInfoMessageEvent, onScrSendKickbackInfo);
});
useEffect(() =>
{

View File

@ -7,10 +7,9 @@ import { NameChangeLayoutViewProps } from './NameChangeView.types';
export const NameChangeConfirmationView:FC<NameChangeLayoutViewProps> = props =>
{
const { username = '', onAction = null } = props;
const [ isConfirming, setIsConfirming ] = useState<boolean>(false);
const onUserNameChangeMessageEvent = useCallback((event: UserNameChangeMessageEvent) =>
useMessageEvent<UserNameChangeMessageEvent>(UserNameChangeMessageEvent, event =>
{
const parser = event.getParser();
@ -19,9 +18,7 @@ export const NameChangeConfirmationView:FC<NameChangeLayoutViewProps> = props =>
if(parser.webId !== GetSessionDataManager().userId) return;
onAction('close');
}, [ onAction ]);
useMessageEvent(UserNameChangeMessageEvent, onUserNameChangeMessageEvent);
});
const confirm = useCallback(() =>
{

View File

@ -20,8 +20,8 @@ export const NameChangeInputView:FC<NameChangeLayoutViewProps> = props =>
const [ isChecking, setIsChecking ] = useState<boolean>(false);
const [ errorCode, setErrorCode ] = useState<string>(null);
const [ suggestions, setSuggestions ] = useState<string[]>([]);
const onCheckUserNameResultMessageEvent = useCallback((event: CheckUserNameResultMessageEvent) =>
useMessageEvent<CheckUserNameResultMessageEvent>(CheckUserNameResultMessageEvent, event =>
{
setIsChecking(false);
@ -50,9 +50,7 @@ export const NameChangeInputView:FC<NameChangeLayoutViewProps> = props =>
case DISABLED:
setErrorCode('change_not_allowed');
}
}, []);
useMessageEvent(CheckUserNameResultMessageEvent, onCheckUserNameResultMessageEvent);
});
const check = useCallback(() =>
{

View File

@ -1,5 +1,5 @@
import { BonusRareInfoMessageEvent, GetBonusRareInfoMessageComposer } from '@nitrots/nitro-renderer';
import { FC, useCallback, useEffect, useState } from 'react';
import { FC, useEffect, useState } from 'react';
import { SendMessageComposer } from '../../../../../api';
import { useMessageEvent } from '../../../../../hooks';
@ -13,7 +13,7 @@ export const BonusRareWidgetView: FC<BonusRareWidgetViewProps> = props =>
const [ totalCoinsForBonus, setTotalCoinsForBonus ] = useState<number>(null);
const [ coinsStillRequiredToBuy, setCoinsStillRequiredToBuy ] = useState<number>(null);
const onBonusRareInfoMessageEvent = useCallback((event: BonusRareInfoMessageEvent) =>
useMessageEvent<BonusRareInfoMessageEvent>(BonusRareInfoMessageEvent, event =>
{
const parser = event.getParser();
@ -21,9 +21,7 @@ export const BonusRareWidgetView: FC<BonusRareWidgetViewProps> = props =>
setProductClassId(parser.productClassId);
setTotalCoinsForBonus(parser.totalCoinsForBonus);
setCoinsStillRequiredToBuy(parser.coinsStillRequiredToBuy);
}, []);
useMessageEvent(BonusRareInfoMessageEvent, onBonusRareInfoMessageEvent);
});
useEffect(() =>
{

View File

@ -1,5 +1,5 @@
import { CommunityGoalHallOfFameData, CommunityGoalHallOfFameMessageEvent, GetCommunityGoalHallOfFameMessageComposer } from '@nitrots/nitro-renderer';
import { FC, useCallback, useEffect, useState } from 'react';
import { FC, useEffect, useState } from 'react';
import { SendMessageComposer } from '../../../../../api';
import { useMessageEvent } from '../../../../../hooks';
import { HallOfFameItemView } from '../hall-of-fame-item/HallOfFameItemView';
@ -10,14 +10,12 @@ export const HallOfFameWidgetView: FC<HallOfFameWidgetViewProps> = props =>
const { slot = -1, conf = null } = props;
const [ data, setData ] = useState<CommunityGoalHallOfFameData>(null);
const onCommunityGoalHallOfFameMessageEvent = useCallback((event: CommunityGoalHallOfFameMessageEvent) =>
useMessageEvent<CommunityGoalHallOfFameMessageEvent>(CommunityGoalHallOfFameMessageEvent, event =>
{
const parser = event.getParser();
setData(parser.data);
}, []);
useMessageEvent(CommunityGoalHallOfFameMessageEvent, onCommunityGoalHallOfFameMessageEvent);
});
useEffect(() =>
{

View File

@ -1,5 +1,5 @@
import { GetPromoArticlesComposer, PromoArticleData, PromoArticlesMessageEvent } from '@nitrots/nitro-renderer';
import { FC, useCallback, useEffect, useState } from 'react';
import { FC, useEffect, useState } from 'react';
import { LocalizeText, OpenUrl, SendMessageComposer } from '../../../../../api';
import { useMessageEvent } from '../../../../../hooks';
@ -8,13 +8,11 @@ export const PromoArticleWidgetView: FC<{}> = props =>
const [ articles, setArticles ] = useState<PromoArticleData[]>(null);
const [ index, setIndex ] = useState(0);
const onPromoArticlesMessageEvent = useCallback((event: PromoArticlesMessageEvent) =>
useMessageEvent<PromoArticlesMessageEvent>(PromoArticlesMessageEvent, event =>
{
const parser = event.getParser();
setArticles(parser.articles);
}, []);
useMessageEvent(PromoArticlesMessageEvent, onPromoArticlesMessageEvent);
});
useEffect(() =>
{

View File

@ -1,5 +1,5 @@
import { BadgePointLimitsEvent, ILinkEventTracker, IRoomSession, RoomEngineObjectEvent, RoomEngineObjectPlacedEvent, RoomPreviewer, RoomSessionEvent } from '@nitrots/nitro-renderer';
import { FC, useCallback, useEffect, useState } from 'react';
import { FC, useEffect, useState } from 'react';
import { AddEventLinkTracker, GetLocalization, GetRoomEngine, isObjectMoverRequested, LocalizeText, RemoveLinkEventTracker, setObjectMoverRequested, UnseenItemCategory } from '../../api';
import { NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../common';
import { useInventoryTrade, useInventoryUnseenTracker, useMessageEvent, useRoomEngineEvent, useRoomSessionManagerEvent } from '../../hooks';
@ -32,18 +32,19 @@ export const InventoryView: FC<{}> = props =>
setIsVisible(false);
}
const onRoomEngineObjectPlacedEvent = useCallback((event: RoomEngineObjectPlacedEvent) =>
useRoomEngineEvent<RoomEngineObjectPlacedEvent>(RoomEngineObjectEvent.PLACED, event =>
{
if(!isObjectMoverRequested()) return;
setObjectMoverRequested(false);
if(!event.placedInRoom) setIsVisible(true);
}, []);
});
useRoomEngineEvent(RoomEngineObjectEvent.PLACED, onRoomEngineObjectPlacedEvent);
const onRoomSessionEvent = useCallback((event: RoomSessionEvent) =>
useRoomSessionManagerEvent<RoomSessionEvent>([
RoomSessionEvent.CREATED,
RoomSessionEvent.ENDED
], event =>
{
switch(event.type)
{
@ -55,19 +56,14 @@ export const InventoryView: FC<{}> = props =>
setIsVisible(false);
return;
}
}, []);
});
useRoomSessionManagerEvent(RoomSessionEvent.CREATED, onRoomSessionEvent);
useRoomSessionManagerEvent(RoomSessionEvent.ENDED, onRoomSessionEvent);
const onBadgePointLimitsEvent = useCallback((event: BadgePointLimitsEvent) =>
useMessageEvent<BadgePointLimitsEvent>(BadgePointLimitsEvent, event =>
{
const parser = event.getParser();
for(const data of parser.data) GetLocalization().setBadgePointLimit(data.badgeId, data.limit);
}, []);
useMessageEvent(BadgePointLimitsEvent, onBadgePointLimitsEvent);
});
useEffect(() =>
{

View File

@ -16,16 +16,14 @@ export const NavigatorRoomSettingsModTabView: FC<NavigatorRoomSettingsTabViewPro
const [ selectedUserId, setSelectedUserId ] = useState<number>(-1);
const [ bannedUsers, setBannedUsers ] = useState<BannedUserData[]>([]);
const onBannedUsersFromRoomEvent = useCallback((event: BannedUsersFromRoomEvent) =>
useMessageEvent<BannedUsersFromRoomEvent>(BannedUsersFromRoomEvent, event =>
{
const parser = event.getParser();
if(!roomData || (roomData.roomId !== parser.roomId)) return;
setBannedUsers(parser.bannedUsers);
}, [ roomData ]);
useMessageEvent(BannedUsersFromRoomEvent, onBannedUsersFromRoomEvent);
});
const unBanUser = useCallback((userId: number) =>
{

View File

@ -1,5 +1,5 @@
import { FlatControllerAddedEvent, FlatControllerRemovedEvent, FlatControllersEvent, RemoveAllRightsMessageComposer, RoomTakeRightsComposer, RoomUsersWithRightsComposer } from '@nitrots/nitro-renderer';
import { FC, useCallback, useEffect, useState } from 'react';
import { FC, useEffect, useState } from 'react';
import { IRoomData, LocalizeText, SendMessageComposer } from '../../../../api';
import { Button, Column, Flex, Grid, Text, UserProfileIconView } from '../../../../common';
import { useMessageEvent } from '../../../../hooks';
@ -15,18 +15,16 @@ export const NavigatorRoomSettingsRightsTabView: FC<NavigatorRoomSettingsTabView
const { roomData = null } = props;
const [ usersWithRights, setUsersWithRights ] = useState<Map<number, string>>(new Map());
const onFlatControllersEvent = useCallback((event: FlatControllersEvent) =>
useMessageEvent<FlatControllersEvent>(FlatControllersEvent, event =>
{
const parser = event.getParser();
if(!roomData || (roomData.roomId !== parser.roomId)) return;
setUsersWithRights(parser.users);
}, [ roomData ]);
});
useMessageEvent(FlatControllersEvent, onFlatControllersEvent);
const onFlatControllerAddedEvent = useCallback((event: FlatControllerAddedEvent) =>
useMessageEvent<FlatControllerAddedEvent>(FlatControllerAddedEvent, event =>
{
const parser = event.getParser();
@ -40,11 +38,9 @@ export const NavigatorRoomSettingsRightsTabView: FC<NavigatorRoomSettingsTabView
return newValue;
});
}, [ roomData ]);
});
useMessageEvent(FlatControllerAddedEvent, onFlatControllerAddedEvent);
const onFlatControllerRemovedEvent = useCallback((event: FlatControllerRemovedEvent) =>
useMessageEvent<FlatControllerRemovedEvent>(FlatControllerRemovedEvent, event =>
{
const parser = event.getParser();
@ -57,10 +53,8 @@ export const NavigatorRoomSettingsRightsTabView: FC<NavigatorRoomSettingsTabView
newValue.delete(parser.userId);
return newValue;
});
}, [ roomData ]);
useMessageEvent(FlatControllerRemovedEvent, onFlatControllerRemovedEvent);
});
});
useEffect(() =>
{

View File

@ -1,5 +1,5 @@
import { RoomBannedUsersComposer, RoomDataParser, RoomSettingsDataEvent, SaveRoomSettingsComposer } from '@nitrots/nitro-renderer';
import { FC, useCallback, useState } from 'react';
import { FC, useState } from 'react';
import { IRoomData, LocalizeText, SendMessageComposer } from '../../../../api';
import { NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../../../common';
import { useMessageEvent } from '../../../../hooks';
@ -22,7 +22,7 @@ export const NavigatorRoomSettingsView: FC<{}> = props =>
const [ roomData, setRoomData ] = useState<IRoomData>(null);
const [ currentTab, setCurrentTab ] = useState(TABS[0]);
const onRoomSettingsEvent = useCallback((event: RoomSettingsDataEvent) =>
useMessageEvent<RoomSettingsDataEvent>(RoomSettingsDataEvent, event =>
{
const parser = event.getParser();
@ -61,9 +61,7 @@ export const NavigatorRoomSettingsView: FC<{}> = props =>
});
SendMessageComposer(new RoomBannedUsersComposer(data.roomId));
}, []);
useMessageEvent(RoomSettingsDataEvent, onRoomSettingsEvent);
});
const onClose = () =>
{

View File

@ -17,15 +17,13 @@ export const ToolbarView: FC<{ isInRoom: boolean }> = props =>
const { requests = [] } = useFriends();
const { iconState = MessengerIconState.HIDDEN } = useMessenger();
const isMod = GetSessionDataManager().isModerator;
const onPerkAllowancesMessageEvent = useCallback((event: PerkAllowancesMessageEvent) =>
useMessageEvent<PerkAllowancesMessageEvent>(PerkAllowancesMessageEvent, event =>
{
const parser = event.getParser();
setUseGuideTool(parser.isAllowed(PerkEnum.USE_GUIDE_TOOL));
}, [ setUseGuideTool ]);
useMessageEvent(PerkAllowancesMessageEvent, onPerkAllowancesMessageEvent);
});
const animationIconToToolbar = useCallback((iconName: string, image: HTMLImageElement, x: number, y: number) =>
{
@ -61,12 +59,10 @@ export const ToolbarView: FC<{ isInRoom: boolean }> = props =>
Motions.runMotion(motion);
}, []);
const onNitroToolbarAnimateIconEvent = useCallback((event: NitroToolbarAnimateIconEvent) =>
useRoomEngineEvent<NitroToolbarAnimateIconEvent>(NitroToolbarAnimateIconEvent.ANIMATE_ICON, event =>
{
animationIconToToolbar('icon-inventory', event.image, event.x, event.y);
}, [ animationIconToToolbar ]);
useRoomEngineEvent(NitroToolbarAnimateIconEvent.ANIMATE_ICON, onNitroToolbarAnimateIconEvent);
});
return (
<>

View File

@ -27,30 +27,26 @@ export const UserProfileView: FC<{}> = props =>
GetUserProfile(userProfile.id);
}, [ userProfile ]);
const onUserCurrentBadgesEvent = useCallback((event: UserCurrentBadgesEvent) =>
useMessageEvent<UserCurrentBadgesEvent>(UserCurrentBadgesEvent, event =>
{
const parser = event.getParser();
if(!userProfile || (parser.userId !== userProfile.id)) return;
setUserBadges(parser.badges);
}, [ userProfile ]);
});
useMessageEvent(UserCurrentBadgesEvent, onUserCurrentBadgesEvent);
const onUserRelationshipsEvent = useCallback((event: RelationshipStatusInfoEvent) =>
useMessageEvent<RelationshipStatusInfoEvent>(RelationshipStatusInfoEvent, event =>
{
const parser = event.getParser();
if(!userProfile || (parser.userId !== userProfile.id)) return;
setUserRelationships(parser);
}, [ userProfile ]);
});
useMessageEvent(RelationshipStatusInfoEvent, onUserRelationshipsEvent);
const onUserProfileEvent = useCallback((event: UserProfileEvent) =>
useMessageEvent<UserProfileEvent>(UserProfileEvent, event =>
{
const parser = event.getParser();
@ -71,11 +67,9 @@ export const UserProfileView: FC<{}> = props =>
SendMessageComposer(new UserCurrentBadgesComposer(parser.id));
SendMessageComposer(new UserRelationshipsComposer(parser.id));
}, []);
});
useMessageEvent(UserProfileEvent, onUserProfileEvent);
const onRoomEngineObjectEvent = useCallback((event: RoomEngineObjectEvent) =>
useRoomEngineEvent<RoomEngineObjectEvent>(RoomEngineObjectEvent.SELECTED, event =>
{
if(!userProfile) return;
@ -86,9 +80,7 @@ export const UserProfileView: FC<{}> = props =>
if(userData.type !== RoomObjectType.USER) return;
GetUserProfile(userData.webID);
}, [ userProfile ]);
useRoomEngineEvent(RoomEngineObjectEvent.SELECTED, onRoomEngineObjectEvent);
});
if(!userProfile) return null;

View File

@ -1,5 +1,5 @@
import { GroupInformationComposer, GroupInformationEvent, GroupInformationParser, HabboGroupEntryData } from '@nitrots/nitro-renderer';
import { FC, useCallback, useEffect, useState } from 'react';
import { FC, useEffect, useState } from 'react';
import { SendMessageComposer, ToggleFavoriteGroup } from '../../../api';
import { AutoGrid, Base, Column, Flex, Grid, GridProps, LayoutBadgeImageView, LayoutGridItem } from '../../../common';
import { useMessageEvent } from '../../../hooks';
@ -18,16 +18,14 @@ export const GroupsContainerView: FC<GroupsContainerViewProps> = props =>
const [ selectedGroupId, setSelectedGroupId ] = useState<number>(null);
const [ groupInformation, setGroupInformation ] = useState<GroupInformationParser>(null);
const onGroupInformationEvent = useCallback((event: GroupInformationEvent) =>
useMessageEvent<GroupInformationEvent>(GroupInformationEvent, event =>
{
const parser = event.getParser();
if(!selectedGroupId || (selectedGroupId !== parser.id) || parser.flag) return;
setGroupInformation(parser);
}, [ selectedGroupId ]);
useMessageEvent(GroupInformationEvent, onGroupInformationEvent);
});
useEffect(() =>
{

View File

@ -416,7 +416,7 @@ const useCatalogState = () =>
}, []);
const onCatalogPagesListEvent = useCallback((event: CatalogPagesListEvent) =>
useMessageEvent<CatalogPagesListEvent>(CatalogPagesListEvent, event =>
{
const parser = event.getParser();
const offers: Map<number, ICatalogNode[]> = new Map();
@ -440,11 +440,9 @@ const useCatalogState = () =>
setRootNode(getCatalogNode(parser.root, 0, null));
setOffersToNodes(offers);
}, [ setRootNode, setOffersToNodes ]);
});
useMessageEvent(CatalogPagesListEvent, onCatalogPagesListEvent);
const onCatalogPageMessageEvent = useCallback((event: CatalogPageMessageEvent) =>
useMessageEvent<CatalogPageMessageEvent>(CatalogPageMessageEvent, event =>
{
const parser = event.getParser();
@ -479,47 +477,37 @@ const useCatalogState = () =>
{
showCatalogPage(parser.pageId, parser.layoutCode, new PageLocalization(parser.localization.images.concat(), parser.localization.texts.concat()), purchasableOffers, parser.offerId, parser.acceptSeasonCurrencyAsCredits);
}
}, [ currentType, pageId, setFrontPageItems, setIsBusy, showCatalogPage ]);
});
useMessageEvent(CatalogPageMessageEvent, onCatalogPageMessageEvent);
const onPurchaseOKMessageEvent = useCallback((event: PurchaseOKMessageEvent) =>
useMessageEvent<PurchaseOKMessageEvent>(PurchaseOKMessageEvent, event =>
{
const parser = event.getParser();
DispatchUiEvent(new CatalogPurchasedEvent(parser.offer));
}, []);
});
useMessageEvent(PurchaseOKMessageEvent, onPurchaseOKMessageEvent);
const onPurchaseErrorMessageEvent = useCallback((event: PurchaseErrorMessageEvent) =>
useMessageEvent<PurchaseErrorMessageEvent>(PurchaseErrorMessageEvent, event =>
{
const parser = event.getParser();
DispatchUiEvent(new CatalogPurchaseFailureEvent(parser.code));
}, []);
});
useMessageEvent(PurchaseErrorMessageEvent, onPurchaseErrorMessageEvent);
const onPurchaseNotAllowedMessageEvent = useCallback((event: PurchaseNotAllowedMessageEvent) =>
useMessageEvent<PurchaseNotAllowedMessageEvent>(PurchaseNotAllowedMessageEvent, event =>
{
const parser = event.getParser();
DispatchUiEvent(new CatalogPurchaseNotAllowedEvent(parser.code));
}, []);
});
useMessageEvent(PurchaseNotAllowedMessageEvent, onPurchaseNotAllowedMessageEvent);
const onLimitedEditionSoldOutEvent = useCallback((event: LimitedEditionSoldOutEvent) =>
useMessageEvent<LimitedEditionSoldOutEvent>(LimitedEditionSoldOutEvent, event =>
{
const parser = event.getParser();
DispatchUiEvent(new CatalogPurchaseSoldOutEvent());
}, []);
});
useMessageEvent(LimitedEditionSoldOutEvent, onLimitedEditionSoldOutEvent);
const onProductOfferEvent = useCallback((event: ProductOfferEvent) =>
useMessageEvent<ProductOfferEvent>(ProductOfferEvent, event =>
{
const parser = event.getParser();
const offerData = parser.offer;
@ -564,11 +552,9 @@ const useCatalogState = () =>
}
// (this._isObjectMoverRequested) && (this._purchasableOffer)
}, [ currentType, currentPage, setCurrentOffer, setPurchaseOptions ]);
});
useMessageEvent(ProductOfferEvent, onProductOfferEvent);
const onSellablePetPalettesMessageEvent = useCallback((event: SellablePetPalettesMessageEvent) =>
useMessageEvent<SellablePetPalettesMessageEvent>(SellablePetPalettesMessageEvent, event =>
{
const parser = event.getParser();
const petPalette = new CatalogPetPalette(parser.productCode, parser.palettes.slice());
@ -595,11 +581,9 @@ const useCatalogState = () =>
return { ...prevValue, petPalettes };
});
}, [ setCatalogOptions ]);
});
useMessageEvent(SellablePetPalettesMessageEvent, onSellablePetPalettesMessageEvent);
const onHabboClubOffersMessageEvent = useCallback((event: HabboClubOffersMessageEvent) =>
useMessageEvent<HabboClubOffersMessageEvent>(HabboClubOffersMessageEvent, event =>
{
const parser = event.getParser();
@ -609,11 +593,9 @@ const useCatalogState = () =>
return { ...prevValue, clubOffers };
});
}, [ setCatalogOptions ]);
});
useMessageEvent(HabboClubOffersMessageEvent, onHabboClubOffersMessageEvent);
const onGuildMembershipsMessageEvent = useCallback((event: GuildMembershipsMessageEvent) =>
useMessageEvent<GuildMembershipsMessageEvent>(GuildMembershipsMessageEvent, event =>
{
const parser = event.getParser();
@ -623,11 +605,9 @@ const useCatalogState = () =>
return { ...prevValue, groups };
});
}, [ setCatalogOptions ]);
});
useMessageEvent(GuildMembershipsMessageEvent, onGuildMembershipsMessageEvent);
const onGiftWrappingConfigurationEvent = useCallback((event: GiftWrappingConfigurationEvent) =>
useMessageEvent<GiftWrappingConfigurationEvent>(GiftWrappingConfigurationEvent, event =>
{
const parser = event.getParser();
@ -637,11 +617,9 @@ const useCatalogState = () =>
return { ...prevValue, giftConfiguration };
});
}, [ setCatalogOptions ]);
});
useMessageEvent(GiftWrappingConfigurationEvent, onGiftWrappingConfigurationEvent);
const onMarketplaceMakeOfferResult = useCallback((event: MarketplaceMakeOfferResult) =>
useMessageEvent<MarketplaceMakeOfferResult>(MarketplaceMakeOfferResult, event =>
{
const parser = event.getParser();
@ -660,11 +638,9 @@ const useCatalogState = () =>
const message = LocalizeText(`inventory.marketplace.result.${ parser.result }`);
simpleAlert(message, NotificationAlertType.DEFAULT, null, null, title);
}, [ simpleAlert ]);
});
useMessageEvent(MarketplaceMakeOfferResult, onMarketplaceMakeOfferResult);
const onClubGiftInfoEvent = useCallback((event: ClubGiftInfoEvent) =>
useMessageEvent<ClubGiftInfoEvent>(ClubGiftInfoEvent, event =>
{
const parser = event.getParser();
@ -674,33 +650,27 @@ const useCatalogState = () =>
return { ...prevValue, clubGifts };
});
}, [ setCatalogOptions ]);
});
useMessageEvent(ClubGiftInfoEvent, onClubGiftInfoEvent);
const onCatalogPublishedMessageEvent = useCallback((event: CatalogPublishedMessageEvent) =>
useMessageEvent<CatalogPublishedMessageEvent>(CatalogPublishedMessageEvent, event =>
{
const wasVisible = isVisible;
resetState();
if(wasVisible) simpleAlert(LocalizeText('catalog.alert.published.description'), NotificationAlertType.ALERT, null, null, LocalizeText('catalog.alert.published.title'));
}, [ isVisible, resetState, simpleAlert ]);
});
useMessageEvent(CatalogPublishedMessageEvent, onCatalogPublishedMessageEvent);
const onBuildersClubFurniCountMessageEvent = useCallback((event: BuildersClubFurniCountMessageEvent) =>
useMessageEvent<BuildersClubFurniCountMessageEvent>(BuildersClubFurniCountMessageEvent, event =>
{
const parser = event.getParser();
setFurniCount(parser.furniCount);
refreshBuilderStatus();
}, [ refreshBuilderStatus ]);
});
useMessageEvent(BuildersClubFurniCountMessageEvent, onBuildersClubFurniCountMessageEvent);
const onBuildersClubSubscriptionStatusMessageEvent = useCallback((event: BuildersClubSubscriptionStatusMessageEvent) =>
useMessageEvent<BuildersClubSubscriptionStatusMessageEvent>(BuildersClubSubscriptionStatusMessageEvent, event =>
{
const parser = event.getParser();
@ -711,18 +681,11 @@ const useCatalogState = () =>
setSecondsLeftWithGrace(parser._Str_24379);
refreshBuilderStatus();
}, [ refreshBuilderStatus ]);
});
useMessageEvent(BuildersClubSubscriptionStatusMessageEvent, onBuildersClubSubscriptionStatusMessageEvent);
useUiEvent<CatalogPurchasedEvent>(CatalogPurchasedEvent.PURCHASE_SUCCESS, event => PlaySound(SoundNames.CREDITS));
const onCatalogPurchasedEvent = useCallback((event: CatalogPurchasedEvent) =>
{
PlaySound(SoundNames.CREDITS);
}, []);
useUiEvent(CatalogPurchasedEvent.PURCHASE_SUCCESS, onCatalogPurchasedEvent);
const onRoomEngineObjectPlacedEvent = useCallback((event: RoomEngineObjectPlacedEvent) =>
useRoomEngineEvent<RoomEngineObjectPlacedEvent>(RoomEngineObjectPlacedEvent.PLACED, event =>
{
if(!objectMoverRequested || (event.type !== RoomEngineObjectPlacedEvent.PLACED)) return;
@ -830,11 +793,9 @@ const useCatalogState = () =>
break;
}
}
}, [ objectMoverRequested, purchasableOffer, catalogPlaceMultipleObjects, catalogSkipPurchaseConfirmation, currentType, pageId, resetPlacedOfferData, resetObjectMover, resetRoomPaint, requestOfferToMover ]);
});
useRoomEngineEvent(RoomEngineObjectPlacedEvent.PLACED, onRoomEngineObjectPlacedEvent);
const onInventoryFurniAddedEvent = useCallback((event: InventoryFurniAddedEvent) =>
useUiEvent<InventoryFurniAddedEvent>(InventoryFurniAddedEvent.FURNI_ADDED, event =>
{
const roomEngine = GetRoomEngine();
@ -865,9 +826,7 @@ const useCatalogState = () =>
}
if(!catalogPlaceMultipleObjects) resetPlacedOfferData();
}, [ placedObjectPurchaseData, catalogPlaceMultipleObjects, resetPlacedOfferData ]);
useUiEvent(InventoryFurniAddedEvent.FURNI_ADDED, onInventoryFurniAddedEvent);
});
useEffect(() =>
{