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

View File

@ -11,17 +11,15 @@ export const CampaignView: FC<{}> = props =>
const [ receivedProducts, setReceivedProducts ] = useState<Map<number, CalendarItem>>(new Map()); const [ receivedProducts, setReceivedProducts ] = useState<Map<number, CalendarItem>>(new Map());
const [ isCalendarOpen, setCalendarOpen ] = useState(false); const [ isCalendarOpen, setCalendarOpen ] = useState(false);
const onCampaignCalendarDataMessageEvent = useCallback((event: CampaignCalendarDataMessageEvent) => useMessageEvent<CampaignCalendarDataMessageEvent>(CampaignCalendarDataMessageEvent, event =>
{ {
const parser = event.getParser(); const parser = event.getParser();
if(!parser) return; if(!parser) return;
setCalendarData(parser.calendarData); setCalendarData(parser.calendarData);
}, []); });
useMessageEvent(CampaignCalendarDataMessageEvent, onCampaignCalendarDataMessageEvent); useMessageEvent<CampaignCalendarDoorOpenedMessageEvent>(CampaignCalendarDoorOpenedMessageEvent, event =>
const onCampaignCalendarDoorOpenedMessageEvent = useCallback((event: CampaignCalendarDoorOpenedMessageEvent) =>
{ {
const parser = event.getParser(); const parser = event.getParser();
@ -49,9 +47,7 @@ export const CampaignView: FC<{}> = props =>
} }
setLastOpenAttempt(-1); setLastOpenAttempt(-1);
}, [ lastOpenAttempt ]); });
useMessageEvent(CampaignCalendarDoorOpenedMessageEvent, onCampaignCalendarDoorOpenedMessageEvent);
const openPackage = useCallback((id: number, asStaff = false) => 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 ]); }, [ extraData, maxBoxIndex, maxRibbonIndex, message, offerId, pageId, receiverName, selectedBoxIndex, selectedColorId, selectedRibbonIndex, showMyFace ]);
const onGiftReceiverNotFoundEvent = useCallback(() => useMessageEvent<GiftReceiverNotFoundEvent>(GiftReceiverNotFoundEvent, event => setReceiverNotFound(true));
{
setReceiverNotFound(true);
}, []);
useMessageEvent(GiftReceiverNotFoundEvent, onGiftReceiverNotFoundEvent);
useEffect(() => useEffect(() =>
{ {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
import { ClubGiftInfoEvent, FriendlyTime, GetClubGiftInfo, ILinkEventTracker, ScrGetKickbackInfoMessageComposer, ScrKickbackData, ScrSendKickbackInfoMessageEvent } from '@nitrots/nitro-renderer'; 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 { OverlayTrigger, Popover } from 'react-bootstrap';
import { AddEventLinkTracker, ClubStatus, CreateLinkEvent, GetClubBadge, GetConfiguration, LocalizeText, RemoveLinkEventTracker, SendMessageComposer } from '../../api'; import { AddEventLinkTracker, ClubStatus, CreateLinkEvent, GetClubBadge, GetConfiguration, LocalizeText, RemoveLinkEventTracker, SendMessageComposer } from '../../api';
import { Base, Button, Column, Flex, LayoutAvatarImageView, LayoutBadgeImageView, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../common'; 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 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 getHcPaydayAmount = () => LocalizeText('hccenter.special.sum', [ 'credits' ], [ (kickbackData.creditRewardForStreakBonus + kickbackData.creditRewardForMonthlySpent).toString() ]);
const onClubGiftInfoEvent = useCallback((event: ClubGiftInfoEvent) => useMessageEvent<ClubGiftInfoEvent>(ClubGiftInfoEvent, event =>
{ {
const parser = event.getParser(); const parser = event.getParser();
setUnclaimedGifts(parser.giftsAvailable); setUnclaimedGifts(parser.giftsAvailable);
}, []); });
useMessageEvent(ClubGiftInfoEvent, onClubGiftInfoEvent); useMessageEvent<ScrSendKickbackInfoMessageEvent>(ScrSendKickbackInfoMessageEvent, event =>
const onScrSendKickbackInfo = useCallback((event: ScrSendKickbackInfoMessageEvent) =>
{ {
const parser = event.getParser(); const parser = event.getParser();
setKickbackData(parser.data); setKickbackData(parser.data);
}, []); });
useMessageEvent(ScrSendKickbackInfoMessageEvent, onScrSendKickbackInfo);
useEffect(() => useEffect(() =>
{ {

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
import { CommunityGoalHallOfFameData, CommunityGoalHallOfFameMessageEvent, GetCommunityGoalHallOfFameMessageComposer } from '@nitrots/nitro-renderer'; 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 { SendMessageComposer } from '../../../../../api';
import { useMessageEvent } from '../../../../../hooks'; import { useMessageEvent } from '../../../../../hooks';
import { HallOfFameItemView } from '../hall-of-fame-item/HallOfFameItemView'; 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 { slot = -1, conf = null } = props;
const [ data, setData ] = useState<CommunityGoalHallOfFameData>(null); const [ data, setData ] = useState<CommunityGoalHallOfFameData>(null);
const onCommunityGoalHallOfFameMessageEvent = useCallback((event: CommunityGoalHallOfFameMessageEvent) => useMessageEvent<CommunityGoalHallOfFameMessageEvent>(CommunityGoalHallOfFameMessageEvent, event =>
{ {
const parser = event.getParser(); const parser = event.getParser();
setData(parser.data); setData(parser.data);
}, []); });
useMessageEvent(CommunityGoalHallOfFameMessageEvent, onCommunityGoalHallOfFameMessageEvent);
useEffect(() => useEffect(() =>
{ {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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