diff --git a/src/App.tsx b/src/App.tsx index e7b054b3..a440354d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -4,10 +4,7 @@ import { GetCommunication, GetConfiguration, GetNitroInstance } from './api'; import { Base, TransitionAnimation, TransitionAnimationTypes } from './common'; import { LoadingView } from './components/loading/LoadingView'; import { MainView } from './components/main/MainView'; -import { useConfigurationEvent } from './hooks/events/core/configuration/configuration-event'; -import { useLocalizationEvent } from './hooks/events/nitro/localization/localization-event'; -import { dispatchMainEvent, useMainEvent } from './hooks/events/nitro/main-event'; -import { useRoomEngineEvent } from './hooks/events/nitro/room/room-engine-event'; +import { DispatchUiEvent, UseConfigurationEvent, UseLocalizationEvent, UseMainEvent, UseRoomEngineEvent } from './hooks'; export const App: FC<{}> = props => { @@ -105,21 +102,21 @@ export const App: FC<{}> = props => } }, [ getPreloadAssetUrls ]); - useMainEvent(Nitro.WEBGL_UNAVAILABLE, handler); - useMainEvent(Nitro.WEBGL_CONTEXT_LOST, handler); - useMainEvent(NitroCommunicationDemoEvent.CONNECTION_HANDSHAKING, handler); - useMainEvent(NitroCommunicationDemoEvent.CONNECTION_HANDSHAKE_FAILED, handler); - useMainEvent(NitroCommunicationDemoEvent.CONNECTION_AUTHENTICATED, handler); - useMainEvent(NitroCommunicationDemoEvent.CONNECTION_ERROR, handler); - useMainEvent(NitroCommunicationDemoEvent.CONNECTION_CLOSED, handler); - useRoomEngineEvent(RoomEngineEvent.ENGINE_INITIALIZED, handler); - useLocalizationEvent(NitroLocalizationEvent.LOADED, handler); - useConfigurationEvent(ConfigurationEvent.LOADED, handler); - useConfigurationEvent(ConfigurationEvent.FAILED, handler); + UseMainEvent(Nitro.WEBGL_UNAVAILABLE, handler); + UseMainEvent(Nitro.WEBGL_CONTEXT_LOST, handler); + UseMainEvent(NitroCommunicationDemoEvent.CONNECTION_HANDSHAKING, handler); + UseMainEvent(NitroCommunicationDemoEvent.CONNECTION_HANDSHAKE_FAILED, handler); + UseMainEvent(NitroCommunicationDemoEvent.CONNECTION_AUTHENTICATED, handler); + UseMainEvent(NitroCommunicationDemoEvent.CONNECTION_ERROR, handler); + UseMainEvent(NitroCommunicationDemoEvent.CONNECTION_CLOSED, handler); + UseRoomEngineEvent(RoomEngineEvent.ENGINE_INITIALIZED, handler); + UseLocalizationEvent(NitroLocalizationEvent.LOADED, handler); + UseConfigurationEvent(ConfigurationEvent.LOADED, handler); + UseConfigurationEvent(ConfigurationEvent.FAILED, handler); if(!WebGL.isWebGLAvailable()) { - dispatchMainEvent(new NitroEvent(Nitro.WEBGL_UNAVAILABLE)); + DispatchUiEvent(new NitroEvent(Nitro.WEBGL_UNAVAILABLE)); } else { diff --git a/src/api/groups/GetGroupInformation.ts b/src/api/groups/GetGroupInformation.ts index 7f37e004..6b4a48cb 100644 --- a/src/api/groups/GetGroupInformation.ts +++ b/src/api/groups/GetGroupInformation.ts @@ -1,7 +1,7 @@ import { GroupInformationComposer } from '@nitrots/nitro-renderer'; -import { SendMessageHook } from '../../hooks'; +import { SendMessageComposer } from '..'; export function GetGroupInformation(groupId: number): void { - SendMessageHook(new GroupInformationComposer(groupId, true)); + SendMessageComposer(new GroupInformationComposer(groupId, true)); } diff --git a/src/api/groups/TryJoinGroup.ts b/src/api/groups/TryJoinGroup.ts index 1b5ee7ff..4fbbcde6 100644 --- a/src/api/groups/TryJoinGroup.ts +++ b/src/api/groups/TryJoinGroup.ts @@ -1,4 +1,4 @@ import { GroupJoinComposer } from '@nitrots/nitro-renderer'; -import { SendMessageHook } from '../../hooks'; +import { SendMessageComposer } from '..'; -export const TryJoinGroup = (groupId: number) => SendMessageHook(new GroupJoinComposer(groupId)); +export const TryJoinGroup = (groupId: number) => SendMessageComposer(new GroupJoinComposer(groupId)); diff --git a/src/api/groups/index.ts b/src/api/groups/index.ts index dba4dff5..1f8b545d 100644 --- a/src/api/groups/index.ts +++ b/src/api/groups/index.ts @@ -1,2 +1,4 @@ export * from './GetGroupInformation'; +export * from './GetGroupManager'; +export * from './GetGroupMembers'; export * from './TryJoinGroup'; diff --git a/src/api/navigator/TryVisitRoom.ts b/src/api/navigator/TryVisitRoom.ts index d8627477..94d8e6fc 100644 --- a/src/api/navigator/TryVisitRoom.ts +++ b/src/api/navigator/TryVisitRoom.ts @@ -1,7 +1,7 @@ import { RoomInfoComposer } from '@nitrots/nitro-renderer'; -import { SendMessageHook } from '../../hooks/messages/message-event'; +import { SendMessageComposer } from '../nitro'; export function TryVisitRoom(roomId: number): void { - SendMessageHook(new RoomInfoComposer(roomId, false, true)); + SendMessageComposer(new RoomInfoComposer(roomId, false, true)); } diff --git a/src/api/nitro/SendMessageComposer.ts b/src/api/nitro/SendMessageComposer.ts new file mode 100644 index 00000000..dd54c02c --- /dev/null +++ b/src/api/nitro/SendMessageComposer.ts @@ -0,0 +1,4 @@ +import { IMessageComposer } from '@nitrots/nitro-renderer'; +import { GetConnection } from './GetConnection'; + +export const SendMessageComposer = (event: IMessageComposer) => GetConnection().send(event); diff --git a/src/api/nitro/index.ts b/src/api/nitro/index.ts index a06d8c49..18b2de0c 100644 --- a/src/api/nitro/index.ts +++ b/src/api/nitro/index.ts @@ -10,4 +10,9 @@ export * from './GetNitroInstance'; export * from './GetTicker'; export * from './RemoveLinkEventTracker'; export * from './room'; +export * from './room/widgets'; +export * from './room/widgets/events'; +export * from './room/widgets/handlers'; +export * from './room/widgets/messages'; +export * from './SendMessageComposer'; export * from './session'; diff --git a/src/api/nitro/room/widgets/events/index.ts b/src/api/nitro/room/widgets/events/index.ts index 6f7406a0..be6a6ae5 100644 --- a/src/api/nitro/room/widgets/events/index.ts +++ b/src/api/nitro/room/widgets/events/index.ts @@ -6,6 +6,7 @@ export * from './RoomWidgetChooserContentEvent'; export * from './RoomWidgetDoorbellEvent'; export * from './RoomWidgetFloodControlEvent'; export * from './RoomWidgetObjectNameEvent'; +export * from './RoomWidgetPollUpdateEvent'; export * from './RoomWidgetUpdateBackgroundColorPreviewEvent'; export * from './RoomWidgetUpdateChatEvent'; export * from './RoomWidgetUpdateChatInputContentEvent'; @@ -34,4 +35,5 @@ export * from './RoomWidgetUpdateTrophyEvent'; export * from './RoomWidgetUpdateUserDataEvent'; export * from './RoomWidgetUpdateYoutubeDisplayEvent'; export * from './RoomWidgetUseProductBubbleEvent'; +export * from './RoomWidgetWordQuizUpdateEvent'; export * from './UseProductItem'; diff --git a/src/api/nitro/room/widgets/handlers/FriendRequestHandler.ts b/src/api/nitro/room/widgets/handlers/FriendRequestHandler.ts index 123b31db..5269341c 100644 --- a/src/api/nitro/room/widgets/handlers/FriendRequestHandler.ts +++ b/src/api/nitro/room/widgets/handlers/FriendRequestHandler.ts @@ -1,6 +1,6 @@ import { NitroEvent, RoomSessionFriendRequestEvent, RoomWidgetEnum } from '@nitrots/nitro-renderer'; import { FriendRequestEvent, FriendsAcceptFriendRequestEvent, FriendsDeclineFriendRequestEvent } from '../../../../../events'; -import { dispatchUiEvent } from '../../../../../hooks'; +import { DispatchUiEvent } from '../../../../../hooks'; import { RoomWidgetUpdateEvent, RoomWidgetUpdateFriendRequestEvent } from '../events'; import { RoomWidgetFriendRequestMessage, RoomWidgetMessage } from '../messages'; import { RoomWidgetHandler } from './RoomWidgetHandler'; @@ -30,10 +30,10 @@ export class FriendRequestHandler extends RoomWidgetHandler switch(message.type) { case RoomWidgetFriendRequestMessage.ACCEPT: - dispatchUiEvent(new FriendsAcceptFriendRequestEvent(friendMessage.requestId)); + DispatchUiEvent(new FriendsAcceptFriendRequestEvent(friendMessage.requestId)); break; case RoomWidgetFriendRequestMessage.DECLINE: - dispatchUiEvent(new FriendsDeclineFriendRequestEvent(friendMessage.requestId)); + DispatchUiEvent(new FriendsDeclineFriendRequestEvent(friendMessage.requestId)); break; } diff --git a/src/api/nitro/room/widgets/handlers/FurnitureDimmerWidgetHandler.ts b/src/api/nitro/room/widgets/handlers/FurnitureDimmerWidgetHandler.ts index 71e35268..b0d62b45 100644 --- a/src/api/nitro/room/widgets/handlers/FurnitureDimmerWidgetHandler.ts +++ b/src/api/nitro/room/widgets/handlers/FurnitureDimmerWidgetHandler.ts @@ -1,10 +1,8 @@ import { NitroEvent, RoomControllerLevel, RoomEngineDimmerStateEvent, RoomEngineTriggerWidgetEvent, RoomSessionDimmerPresetsEvent, RoomWidgetEnum } from '@nitrots/nitro-renderer'; import { GetRoomEngine } from '../..'; import { GetSessionDataManager } from '../../..'; -import { RoomWidgetUpdateDimmerEvent, RoomWidgetUpdateEvent } from '../events'; -import { RoomWidgetUpdateDimmerStateEvent } from '../events/RoomWidgetUpdateDimmerStateEvent'; -import { RoomWidgetDimmerChangeStateMessage, RoomWidgetDimmerPreviewMessage, RoomWidgetFurniToWidgetMessage, RoomWidgetMessage } from '../messages'; -import { RoomWidgetDimmerSavePresetMessage } from '../messages/RoomWidgetDimmerSavePresetMessage'; +import { RoomWidgetUpdateDimmerEvent, RoomWidgetUpdateDimmerStateEvent, RoomWidgetUpdateEvent } from '../events'; +import { RoomWidgetDimmerChangeStateMessage, RoomWidgetDimmerPreviewMessage, RoomWidgetDimmerSavePresetMessage, RoomWidgetFurniToWidgetMessage, RoomWidgetMessage } from '../messages'; import { RoomWidgetHandler } from './RoomWidgetHandler'; export class FurnitureDimmerWidgetHandler extends RoomWidgetHandler diff --git a/src/api/nitro/room/widgets/handlers/FurnitureExternalImageWidgetHandler.ts b/src/api/nitro/room/widgets/handlers/FurnitureExternalImageWidgetHandler.ts index 1c504817..b3323520 100644 --- a/src/api/nitro/room/widgets/handlers/FurnitureExternalImageWidgetHandler.ts +++ b/src/api/nitro/room/widgets/handlers/FurnitureExternalImageWidgetHandler.ts @@ -1,8 +1,6 @@ import { NitroEvent, RoomEngineTriggerWidgetEvent, RoomObjectVariable, RoomWidgetEnum } from '@nitrots/nitro-renderer'; import { GetRoomEngine } from '../../../..'; -import { IPhotoData } from '../events'; -import { RoomWidgetUpdateEvent } from '../events/RoomWidgetUpdateEvent'; -import { RoomWidgetUpdateExternalImageEvent } from '../events/RoomWidgetUpdateExternalImageEvent'; +import { IPhotoData, RoomWidgetUpdateEvent, RoomWidgetUpdateExternalImageEvent } from '../events'; import { RoomWidgetMessage } from '../messages/RoomWidgetMessage'; import { RoomWidgetHandler } from './RoomWidgetHandler'; diff --git a/src/api/nitro/room/widgets/handlers/FurnitureMannequinWidgetHandler.ts b/src/api/nitro/room/widgets/handlers/FurnitureMannequinWidgetHandler.ts index a2fc46bd..75864ee7 100644 --- a/src/api/nitro/room/widgets/handlers/FurnitureMannequinWidgetHandler.ts +++ b/src/api/nitro/room/widgets/handlers/FurnitureMannequinWidgetHandler.ts @@ -1,8 +1,8 @@ import { NitroEvent, RoomEngineTriggerWidgetEvent, RoomObjectVariable, RoomWidgetEnum } from '@nitrots/nitro-renderer'; import { RoomWidgetUpdateMannequinEvent } from '..'; import { GetRoomEngine } from '../../GetRoomEngine'; -import { RoomWidgetUpdateEvent } from '../events/RoomWidgetUpdateEvent'; -import { RoomWidgetMessage } from '../messages/RoomWidgetMessage'; +import { RoomWidgetUpdateEvent } from '../events'; +import { RoomWidgetMessage } from '../messages'; import { RoomWidgetHandler } from './RoomWidgetHandler'; export class FurnitureMannequinWidgetHandler extends RoomWidgetHandler diff --git a/src/api/nitro/room/widgets/handlers/FurnitureYoutubeDisplayWidgetHandler.ts b/src/api/nitro/room/widgets/handlers/FurnitureYoutubeDisplayWidgetHandler.ts index a8c0a15b..8974053b 100644 --- a/src/api/nitro/room/widgets/handlers/FurnitureYoutubeDisplayWidgetHandler.ts +++ b/src/api/nitro/room/widgets/handlers/FurnitureYoutubeDisplayWidgetHandler.ts @@ -1,13 +1,9 @@ -import { SecurityLevel } from '@nitrots/nitro-renderer'; -import { NitroEvent } from '@nitrots/nitro-renderer/src/core/events/NitroEvent'; -import { GetYoutubeDisplayStatusMessageComposer } from '@nitrots/nitro-renderer/src/nitro/communication/messages/outgoing/room/furniture/youtube'; -import { RoomEngineTriggerWidgetEvent } from '@nitrots/nitro-renderer/src/nitro/room/events/RoomEngineTriggerWidgetEvent'; -import { RoomWidgetEnum } from '@nitrots/nitro-renderer/src/nitro/ui/widget/enums/RoomWidgetEnum'; +import { GetYoutubeDisplayStatusMessageComposer, NitroEvent, RoomWidgetEnum, SecurityLevel } from '@nitrots/nitro-renderer'; +import { RoomEngineTriggerWidgetEvent } from '@nitrots/nitro-renderer/'; import { RoomWidgetMessage, RoomWidgetUpdateEvent } from '..'; -import { GetSessionDataManager, IsOwnerOfFurniture } from '../../..'; -import { SendMessageHook } from '../../../../../hooks'; +import { GetSessionDataManager, IsOwnerOfFurniture, SendMessageComposer } from '../../..'; import { GetRoomEngine } from '../../GetRoomEngine'; -import { RoomWidgetUpdateYoutubeDisplayEvent } from '../events/RoomWidgetUpdateYoutubeDisplayEvent'; +import { RoomWidgetUpdateYoutubeDisplayEvent } from '../events'; import { RoomWidgetHandler } from './RoomWidgetHandler'; export class FurnitureYoutubeDisplayWidgetHandler extends RoomWidgetHandler @@ -34,7 +30,7 @@ export class FurnitureYoutubeDisplayWidgetHandler extends RoomWidgetHandler const hasControl = GetSessionDataManager().hasSecurity(SecurityLevel.EMPLOYEE) || IsOwnerOfFurniture(roomObject); this.container.eventDispatcher.dispatchEvent(new RoomWidgetUpdateYoutubeDisplayEvent(roomObject.id, hasControl)); - SendMessageHook(new GetYoutubeDisplayStatusMessageComposer(this._lastFurniId)); + SendMessageComposer(new GetYoutubeDisplayStatusMessageComposer(this._lastFurniId)); return; } case RoomEngineTriggerWidgetEvent.CLOSE_WIDGET: { diff --git a/src/api/nitro/room/widgets/handlers/PollWidgetHandler.ts b/src/api/nitro/room/widgets/handlers/PollWidgetHandler.ts index 0d1b0457..65330784 100644 --- a/src/api/nitro/room/widgets/handlers/PollWidgetHandler.ts +++ b/src/api/nitro/room/widgets/handlers/PollWidgetHandler.ts @@ -1,8 +1,6 @@ import { NitroEvent, RoomSessionPollEvent, RoomWidgetEnum } from '@nitrots/nitro-renderer'; -import { RoomWidgetPollUpdateEvent } from '../events/RoomWidgetPollUpdateEvent'; -import { RoomWidgetUpdateEvent } from '../events/RoomWidgetUpdateEvent'; -import { RoomWidgetMessage } from '../messages/RoomWidgetMessage'; -import { RoomWidgetPollMessage } from '../messages/RoomWidgetPollMessage'; +import { RoomWidgetPollUpdateEvent, RoomWidgetUpdateEvent } from '../events'; +import { RoomWidgetMessage, RoomWidgetPollMessage } from '../messages'; import { RoomWidgetHandler } from './RoomWidgetHandler'; export class PollWidgetHandler extends RoomWidgetHandler diff --git a/src/api/nitro/room/widgets/handlers/RoomWidgetChatInputHandler.ts b/src/api/nitro/room/widgets/handlers/RoomWidgetChatInputHandler.ts index 879f8367..48e30ca6 100644 --- a/src/api/nitro/room/widgets/handlers/RoomWidgetChatInputHandler.ts +++ b/src/api/nitro/room/widgets/handlers/RoomWidgetChatInputHandler.ts @@ -1,9 +1,8 @@ import { AvatarExpressionEnum, HabboClubLevelEnum, NitroEvent, RoomControllerLevel, RoomRotatingEffect, RoomSessionChatEvent, RoomSettingsComposer, RoomShakingEffect, RoomWidgetEnum, RoomZoomEvent, TextureUtils } from '@nitrots/nitro-renderer'; -import { GetConfiguration, GetNitroInstance } from '../../..'; +import { GetConfiguration, GetNitroInstance, SendMessageComposer } from '../../..'; import { GetRoomEngine, GetSessionDataManager, LocalizeText } from '../../../..'; import { FloorplanEditorEvent } from '../../../../../events/floorplan-editor/FloorplanEditorEvent'; -import { dispatchUiEvent } from '../../../../../hooks'; -import { SendMessageHook } from '../../../../../hooks/messages'; +import { DispatchUiEvent } from '../../../../../hooks'; import { NotificationUtilities } from '../../../../../views/notification-center/common/NotificationUtilities'; import { RoomWidgetFloodControlEvent, RoomWidgetUpdateEvent } from '../events'; import { RoomWidgetChatMessage, RoomWidgetChatSelectAvatarMessage, RoomWidgetChatTypingMessage, RoomWidgetMessage, RoomWidgetRequestWidgetMessage } from '../messages'; @@ -160,7 +159,7 @@ export class RoomWidgetChatInputHandler extends RoomWidgetHandler if(this.container.roomSession.controllerLevel >= RoomControllerLevel.ROOM_OWNER) { //this.container.processWidgetMessage(new RoomWidgetRequestWidgetMessage(RoomWidgetRequestWidgetMessage.FLOOR_EDITOR)); - dispatchUiEvent(new FloorplanEditorEvent(FloorplanEditorEvent.SHOW_FLOORPLAN_EDITOR)); + DispatchUiEvent(new FloorplanEditorEvent(FloorplanEditorEvent.SHOW_FLOORPLAN_EDITOR)); } return null; @@ -179,7 +178,7 @@ export class RoomWidgetChatInputHandler extends RoomWidgetHandler case ':settings': if(this.container.roomSession.isRoomOwner || GetSessionDataManager().isModerator) { - SendMessageHook(new RoomSettingsComposer(this.container.roomSession.roomId)); + SendMessageComposer(new RoomSettingsComposer(this.container.roomSession.roomId)); } return null; diff --git a/src/api/nitro/room/widgets/handlers/RoomWidgetInfostandHandler.ts b/src/api/nitro/room/widgets/handlers/RoomWidgetInfostandHandler.ts index b3af10a0..e411ca17 100644 --- a/src/api/nitro/room/widgets/handlers/RoomWidgetInfostandHandler.ts +++ b/src/api/nitro/room/widgets/handlers/RoomWidgetInfostandHandler.ts @@ -1,10 +1,8 @@ import { IFurnitureData, NitroEvent, ObjectDataFactory, PetFigureData, PetRespectComposer, PetSupplementComposer, PetType, RoomControllerLevel, RoomModerationSettings, RoomObjectCategory, RoomObjectOperationType, RoomObjectType, RoomObjectVariable, RoomSessionPetInfoUpdateEvent, RoomSessionUserBadgesEvent, RoomSessionUserFigureUpdateEvent, RoomTradingLevelEnum, RoomUnitDropHandItemComposer, RoomUnitGiveHandItemComposer, RoomUnitGiveHandItemPetComposer, RoomUserData, RoomWidgetEnum, RoomWidgetEnumItemExtradataParameter, Vector3d } from '@nitrots/nitro-renderer'; +import { SendMessageComposer } from '../../..'; import { GetNitroInstance, GetRoomEngine, GetSessionDataManager, IsOwnerOfFurniture } from '../../../..'; -import { InventoryTradeRequestEvent, WiredSelectObjectEvent } from '../../../../../events'; -import { FriendsSendFriendRequestEvent } from '../../../../../events/friends/FriendsSendFriendRequestEvent'; -import { HelpReportUserEvent } from '../../../../../events/help/HelpReportUserEvent'; -import { dispatchUiEvent } from '../../../../../hooks/events'; -import { SendMessageHook } from '../../../../../hooks/messages'; +import { FriendsSendFriendRequestEvent, HelpReportUserEvent, InventoryTradeRequestEvent, WiredSelectObjectEvent } from '../../../../../events'; +import { DispatchUiEvent } from '../../../../../hooks'; import { FriendsHelper } from '../../../../../views/friends/common/FriendsHelper'; import { PetSupplementEnum } from '../../../../../views/room/widgets/avatar-info/common/PetSupplementEnum'; import { LocalizeText } from '../../../../utils/LocalizeText'; @@ -81,7 +79,7 @@ export class RoomWidgetInfostandHandler extends RoomWidgetHandler case RoomWidgetRoomObjectMessage.GET_OBJECT_INFO: return this.processObjectInfoMessage((message as RoomWidgetRoomObjectMessage)); case RoomWidgetUserActionMessage.SEND_FRIEND_REQUEST: - dispatchUiEvent(new FriendsSendFriendRequestEvent(userData.webID, userData.name)); + DispatchUiEvent(new FriendsSendFriendRequestEvent(userData.webID, userData.name)); break; case RoomWidgetUserActionMessage.RESPECT_USER: GetSessionDataManager().giveRespect(userId); @@ -122,7 +120,7 @@ export class RoomWidgetInfostandHandler extends RoomWidgetHandler this.container.roomSession.sendTakeRightsMessage((message as RoomWidgetUserActionMessage).userId); break; case RoomWidgetUserActionMessage.START_TRADING: - dispatchUiEvent(new InventoryTradeRequestEvent(userData.roomIndex, userData.name)); + DispatchUiEvent(new InventoryTradeRequestEvent(userData.roomIndex, userData.name)); break; // case RoomWidgetUserActionMessage.RWUAM_OPEN_HOME_PAGE: // this._container.sessionDataManager._Str_21275((message as RoomWidgetUserActionMessage).userId, _local_3.name); @@ -146,22 +144,22 @@ export class RoomWidgetInfostandHandler extends RoomWidgetHandler this.container.roomSession.removePetSaddle(userId); break; case RoomWidgetUserActionMessage.PASS_CARRY_ITEM: - SendMessageHook(new RoomUnitGiveHandItemComposer(userId)); + SendMessageComposer(new RoomUnitGiveHandItemComposer(userId)); break; case RoomWidgetUserActionMessage.GIVE_CARRY_ITEM_TO_PET: - SendMessageHook(new RoomUnitGiveHandItemPetComposer(userId)); + SendMessageComposer(new RoomUnitGiveHandItemPetComposer(userId)); break; case RoomWidgetUserActionMessage.GIVE_WATER_TO_PET: - SendMessageHook(new PetSupplementComposer(userId, PetSupplementEnum.WATER)); + SendMessageComposer(new PetSupplementComposer(userId, PetSupplementEnum.WATER)); break; case RoomWidgetUserActionMessage.GIVE_LIGHT_TO_PET: - SendMessageHook(new PetSupplementComposer(userId, PetSupplementEnum.LIGHT)); + SendMessageComposer(new PetSupplementComposer(userId, PetSupplementEnum.LIGHT)); break; case RoomWidgetUserActionMessage.TREAT_PET: - SendMessageHook(new PetRespectComposer(userId)); + SendMessageComposer(new PetRespectComposer(userId)); break; case RoomWidgetUserActionMessage.DROP_CARRY_ITEM: - SendMessageHook(new RoomUnitDropHandItemComposer()); + SendMessageComposer(new RoomUnitDropHandItemComposer()); break; case RoomWidgetUserActionMessage.REQUEST_PET_UPDATE: this.container.roomSession.userDataManager.requestPetInfo(userId); @@ -169,7 +167,7 @@ export class RoomWidgetInfostandHandler extends RoomWidgetHandler case RoomWidgetUserActionMessage.REPORT: return; case RoomWidgetUserActionMessage.REPORT_CFH_OTHER: - dispatchUiEvent(new HelpReportUserEvent(userId)); + DispatchUiEvent(new HelpReportUserEvent(userId)); return; case RoomWidgetUserActionMessage.AMBASSADOR_ALERT_USER: this.container.roomSession.sendAmbassadorAlertMessage(userId); @@ -391,7 +389,7 @@ export class RoomWidgetInfostandHandler extends RoomWidgetHandler event.tileSizeX = furnitureData.tileSizeX; event.tileSizeY = furnitureData.tileSizeY; - dispatchUiEvent(new WiredSelectObjectEvent(event.id, event.category)); + DispatchUiEvent(new WiredSelectObjectEvent(event.id, event.category)); } } diff --git a/src/api/nitro/room/widgets/messages/index.ts b/src/api/nitro/room/widgets/messages/index.ts index c3d1bd48..9fdaba24 100644 --- a/src/api/nitro/room/widgets/messages/index.ts +++ b/src/api/nitro/room/widgets/messages/index.ts @@ -14,6 +14,7 @@ export * from './RoomWidgetFurniActionMessage'; export * from './RoomWidgetFurniToWidgetMessage'; export * from './RoomWidgetLetUserInMessage'; export * from './RoomWidgetMessage'; +export * from './RoomWidgetPollMessage'; export * from './RoomWidgetPresentOpenMessage'; export * from './RoomWidgetRequestWidgetMessage'; export * from './RoomWidgetRoomObjectMessage'; diff --git a/src/api/nitro/session/GoToDesktop.ts b/src/api/nitro/session/GoToDesktop.ts index 4617043c..1bbe0168 100644 --- a/src/api/nitro/session/GoToDesktop.ts +++ b/src/api/nitro/session/GoToDesktop.ts @@ -1,7 +1,7 @@ import { DesktopViewComposer } from '@nitrots/nitro-renderer'; -import { SendMessageHook } from '../../../hooks'; +import { SendMessageComposer } from '..'; export function GoToDesktop(): void { - SendMessageHook(new DesktopViewComposer()); + SendMessageComposer(new DesktopViewComposer()); } diff --git a/src/api/user/GetUserProfile.ts b/src/api/user/GetUserProfile.ts index d29f7ff5..0f2be773 100644 --- a/src/api/user/GetUserProfile.ts +++ b/src/api/user/GetUserProfile.ts @@ -1,7 +1,7 @@ import { UserProfileComposer } from '@nitrots/nitro-renderer'; -import { SendMessageHook } from '../../hooks'; +import { SendMessageComposer } from '..'; export function GetUserProfile(userId: number): void { - SendMessageHook(new UserProfileComposer(userId)); + SendMessageComposer(new UserProfileComposer(userId)); } diff --git a/src/api/utils/PlaySound.ts b/src/api/utils/PlaySound.ts index 96bc8fc5..d07ceb7c 100644 --- a/src/api/utils/PlaySound.ts +++ b/src/api/utils/PlaySound.ts @@ -1,9 +1,9 @@ import { NitroSoundEvent } from '@nitrots/nitro-renderer/src/nitro/events/NitroSoundEvent'; -import { dispatchMainEvent } from '../../hooks'; +import { DispatchMainEvent } from '../../hooks'; export function PlaySound(sampleCode: string): void { - dispatchMainEvent(new NitroSoundEvent(NitroSoundEvent.PLAY_SOUND, sampleCode)); + DispatchMainEvent(new NitroSoundEvent(NitroSoundEvent.PLAY_SOUND, sampleCode)); } export const CAMERA_SHUTTER = 'camera_shutter'; diff --git a/src/components/achievements/AchievementsView.tsx b/src/components/achievements/AchievementsView.tsx index 2831d113..a7f30f2f 100644 --- a/src/components/achievements/AchievementsView.tsx +++ b/src/components/achievements/AchievementsView.tsx @@ -1,14 +1,9 @@ import { AchievementData, AchievementEvent, AchievementsEvent, AchievementsScoreEvent, RequestAchievementsMessageComposer } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useMemo, useState } from 'react'; -import { GetConfiguration, LocalizeText } from '../../api'; -import { NitroCardContentView, NitroCardHeaderView, NitroCardSubHeaderView, NitroCardView } from '../../common'; -import { Base } from '../../common/Base'; -import { Column } from '../../common/Column'; -import { Flex } from '../../common/Flex'; -import { Text } from '../../common/Text'; -import { AchievementsUIEvent, AchievementsUIUnseenCountEvent } from '../../events/achievements'; -import { BatchUpdates, CreateMessageHook, dispatchUiEvent, SendMessageHook } from '../../hooks'; -import { useUiEvent } from '../../hooks/events'; +import { GetConfiguration, LocalizeText, SendMessageComposer } from '../../api'; +import { Base, Column, Flex, NitroCardContentView, NitroCardHeaderView, NitroCardSubHeaderView, NitroCardView, Text } from '../../common'; +import { AchievementsUIEvent, AchievementsUIUnseenCountEvent } from '../../events'; +import { BatchUpdates, DispatchUiEvent, UseMessageEventHook, UseUiEvent } from '../../hooks'; import { AchievementCategory } from './common/AchievementCategory'; import { AchievementUtilities } from './common/AchievementUtilities'; import { AchievementsCategoryListView } from './views/category-list/AchievementsCategoryListView'; @@ -38,9 +33,9 @@ export const AchievementsView: FC<{}> = props => } }, []); - useUiEvent(AchievementsUIEvent.SHOW_ACHIEVEMENTS, onAchievementsUIEvent); - useUiEvent(AchievementsUIEvent.HIDE_ACHIEVEMENTS, onAchievementsUIEvent); - useUiEvent(AchievementsUIEvent.TOGGLE_ACHIEVEMENTS, onAchievementsUIEvent); + UseUiEvent(AchievementsUIEvent.SHOW_ACHIEVEMENTS, onAchievementsUIEvent); + UseUiEvent(AchievementsUIEvent.HIDE_ACHIEVEMENTS, onAchievementsUIEvent); + UseUiEvent(AchievementsUIEvent.TOGGLE_ACHIEVEMENTS, onAchievementsUIEvent); const onAchievementEvent = useCallback((event: AchievementEvent) => { @@ -89,7 +84,7 @@ export const AchievementsView: FC<{}> = props => setAchievementCategories(newCategories); }, [ achievementCategories ]); - CreateMessageHook(AchievementEvent, onAchievementEvent); + UseMessageEventHook(AchievementEvent, onAchievementEvent); const onAchievementsEvent = useCallback((event: AchievementsEvent) => { @@ -119,7 +114,7 @@ export const AchievementsView: FC<{}> = props => }); }, []); - CreateMessageHook(AchievementsEvent, onAchievementsEvent); + UseMessageEventHook(AchievementsEvent, onAchievementsEvent); const onAchievementsScoreEvent = useCallback((event: AchievementsScoreEvent) => { @@ -128,7 +123,7 @@ export const AchievementsView: FC<{}> = props => setAchievementScore(parser.score); }, []); - CreateMessageHook(AchievementsScoreEvent, onAchievementsScoreEvent); + UseMessageEventHook(AchievementsScoreEvent, onAchievementsScoreEvent); const getTotalUnseen = useMemo(() => { @@ -204,12 +199,12 @@ export const AchievementsView: FC<{}> = props => { if(!isVisible || !isInitalized) return; - SendMessageHook(new RequestAchievementsMessageComposer()); + SendMessageComposer(new RequestAchievementsMessageComposer()); }, [ isVisible, isInitalized ]); useEffect(() => { - dispatchUiEvent(new AchievementsUIUnseenCountEvent(getTotalUnseen)); + DispatchUiEvent(new AchievementsUIUnseenCountEvent(getTotalUnseen)); }, [ getTotalUnseen ]); if(!isVisible || !isInitalized) return null; diff --git a/src/components/avatar-editor/AvatarEditorView.tsx b/src/components/avatar-editor/AvatarEditorView.tsx index 10ba06f5..77c08167 100644 --- a/src/components/avatar-editor/AvatarEditorView.tsx +++ b/src/components/avatar-editor/AvatarEditorView.tsx @@ -1,13 +1,13 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { AvatarEditorFigureCategory, FigureSetIdsMessageEvent, GetWardrobeMessageComposer, IAvatarFigureContainer, ILinkEventTracker, UserFigureComposer, UserWardrobePageEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useMemo, useState } from 'react'; -import { AddEventLinkTracker, GetAvatarRenderManager, GetClubMemberLevel, GetConfiguration, GetSessionDataManager, LocalizeText, RemoveLinkEventTracker } from '../../api'; +import { AddEventLinkTracker, GetAvatarRenderManager, GetClubMemberLevel, GetConfiguration, GetSessionDataManager, LocalizeText, RemoveLinkEventTracker, SendMessageComposer } from '../../api'; import { NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../common'; import { Button } from '../../common/Button'; import { ButtonGroup } from '../../common/ButtonGroup'; import { Column } from '../../common/Column'; import { Grid } from '../../common/Grid'; -import { CreateMessageHook, SendMessageHook } from '../../hooks'; +import { UseMessageEventHook } from '../../hooks'; import { AvatarEditorAction } from './common/AvatarEditorAction'; import { AvatarEditorUtilities } from './common/AvatarEditorUtilities'; import { BodyModel } from './common/BodyModel'; @@ -50,7 +50,7 @@ export const AvatarEditorView: FC<{}> = props => setBoundFurnitureNames(parser.boundsFurnitureNames); }, []); - CreateMessageHook(FigureSetIdsMessageEvent, onFigureSetIdsMessageEvent); + UseMessageEventHook(FigureSetIdsMessageEvent, onFigureSetIdsMessageEvent); const onUserWardrobePageEvent = useCallback((event: UserWardrobePageEvent) => { @@ -76,7 +76,7 @@ export const AvatarEditorView: FC<{}> = props => setSavedFigures(savedFigures) }, [ maxWardrobeSlots ]); - CreateMessageHook(UserWardrobePageEvent, onUserWardrobePageEvent); + UseMessageEventHook(UserWardrobePageEvent, onUserWardrobePageEvent); const selectCategory = useCallback((name: string) => { @@ -152,7 +152,7 @@ export const AvatarEditorView: FC<{}> = props => resetCategories(); return; case AvatarEditorAction.ACTION_SAVE: - SendMessageHook(new UserFigureComposer(figureData.gender, figureData.getFigureString())); + SendMessageComposer(new UserFigureComposer(figureData.gender, figureData.getFigureString())); setIsVisible(false); return; } @@ -214,7 +214,7 @@ export const AvatarEditorView: FC<{}> = props => if(!isWardrobeVisible) return; setActiveCategory(null); - SendMessageHook(new GetWardrobeMessageComposer()); + SendMessageComposer(new GetWardrobeMessageComposer()); }, [ isWardrobeVisible ]); useEffect(() => diff --git a/src/components/avatar-editor/views/wardrobe/AvatarEditorWardrobeView.tsx b/src/components/avatar-editor/views/wardrobe/AvatarEditorWardrobeView.tsx index c35917a1..a5e8c616 100644 --- a/src/components/avatar-editor/views/wardrobe/AvatarEditorWardrobeView.tsx +++ b/src/components/avatar-editor/views/wardrobe/AvatarEditorWardrobeView.tsx @@ -1,8 +1,7 @@ import { IAvatarFigureContainer, SaveWardrobeOutfitMessageComposer } from '@nitrots/nitro-renderer'; import { Dispatch, FC, SetStateAction, useCallback, useMemo } from 'react'; -import { GetAvatarRenderManager, GetSessionDataManager } from '../../../../api'; +import { GetAvatarRenderManager, GetSessionDataManager, SendMessageComposer } from '../../../../api'; import { AutoGrid, Base, Button, Flex, LayoutGridItem } from '../../../../common'; -import { SendMessageHook } from '../../../../hooks'; import { AvatarImageView } from '../../../../views/shared/avatar-image/AvatarImageView'; import { CurrencyIcon } from '../../../../views/shared/currency-icon/CurrencyIcon'; import { FigureData } from '../../common/FigureData'; @@ -40,7 +39,7 @@ export const AvatarEditorWardrobeView: FC = props newFigures[index] = [ GetAvatarRenderManager().createFigureContainer(figure), gender ]; setSavedFigures(newFigures); - SendMessageHook(new SaveWardrobeOutfitMessageComposer((index + 1), figure, gender)); + SendMessageComposer(new SaveWardrobeOutfitMessageComposer((index + 1), figure, gender)); }, [ figureData, savedFigures, setSavedFigures ]); const figures = useMemo(() => diff --git a/src/components/camera/CameraWidgetView.tsx b/src/components/camera/CameraWidgetView.tsx index 4fb09627..aab9d341 100644 --- a/src/components/camera/CameraWidgetView.tsx +++ b/src/components/camera/CameraWidgetView.tsx @@ -1,9 +1,7 @@ import { ILinkEventTracker, InitCameraMessageEvent, IRoomCameraWidgetEffect, RequestCameraConfigurationComposer, RoomCameraWidgetManagerEvent, RoomSessionEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; -import { AddEventLinkTracker, GetRoomCameraWidgetManager, RemoveLinkEventTracker } from '../../api'; -import { useRoomSessionManagerEvent } from '../../hooks'; -import { useCameraEvent } from '../../hooks/events/nitro/camera/camera-event'; -import { CreateMessageHook, SendMessageHook } from '../../hooks/messages/message-event'; +import { AddEventLinkTracker, GetRoomCameraWidgetManager, RemoveLinkEventTracker, SendMessageComposer } from '../../api'; +import { UseCameraEvent, UseMessageEventHook, UseRoomSessionManagerEvent } from '../../hooks'; import { CameraWidgetContextProvider } from './CameraWidgetContext'; import { CameraPicture } from './common/CameraPicture'; import { CameraWidgetCaptureView } from './views/capture/CameraWidgetCaptureView'; @@ -30,7 +28,7 @@ export const CameraWidgetView: FC<{}> = props => setAvailableEffects(Array.from(GetRoomCameraWidgetManager().effects.values())) }, []); - useCameraEvent(RoomCameraWidgetManagerEvent.INITIALIZED, onRoomCameraWidgetManagerEvent); + UseCameraEvent(RoomCameraWidgetManagerEvent.INITIALIZED, onRoomCameraWidgetManagerEvent); const onCameraConfigurationEvent = useCallback((event: InitCameraMessageEvent) => { @@ -39,14 +37,14 @@ export const CameraWidgetView: FC<{}> = props => setPrice({ credits: parser.creditPrice, duckets: parser.ducketPrice, publishDucketPrice: parser.publishDucketPrice }); }, []); - CreateMessageHook(InitCameraMessageEvent, onCameraConfigurationEvent); + UseMessageEventHook(InitCameraMessageEvent, onCameraConfigurationEvent); const onRoomSessionEvent = useCallback((event: RoomSessionEvent) => { setMode(MODE_NONE); }, []); - useRoomSessionManagerEvent(RoomSessionEvent.ENDED, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionEvent.ENDED, onRoomSessionEvent); useEffect(() => { @@ -54,7 +52,7 @@ export const CameraWidgetView: FC<{}> = props => { GetRoomCameraWidgetManager().init(); - SendMessageHook(new RequestCameraConfigurationComposer()); + SendMessageComposer(new RequestCameraConfigurationComposer()); return; } diff --git a/src/components/camera/views/checkout/CameraWidgetCheckoutView.tsx b/src/components/camera/views/checkout/CameraWidgetCheckoutView.tsx index 5363999c..83279eeb 100644 --- a/src/components/camera/views/checkout/CameraWidgetCheckoutView.tsx +++ b/src/components/camera/views/checkout/CameraWidgetCheckoutView.tsx @@ -1,9 +1,9 @@ import { CameraPublishStatusMessageEvent, CameraPurchaseOKMessageEvent, CameraStorageUrlMessageEvent, PublishPhotoMessageComposer, PurchasePhotoMessageComposer } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; -import { GetConfiguration, GetRoomEngine, LocalizeText } from '../../../../api'; +import { GetConfiguration, GetRoomEngine, LocalizeText, SendMessageComposer } from '../../../../api'; import { Button, Column, Flex, LayoutImage, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../../common'; import { InventoryEvent } from '../../../../events'; -import { BatchUpdates, CreateMessageHook, dispatchUiEvent, SendMessageHook } from '../../../../hooks'; +import { BatchUpdates, DispatchUiEvent, UseMessageEventHook } from '../../../../hooks'; import { CurrencyIcon } from '../../../../views/shared/currency-icon/CurrencyIcon'; export interface CameraWidgetCheckoutViewProps @@ -33,7 +33,7 @@ export const CameraWidgetCheckoutView: FC = props }); }, []); - CreateMessageHook(CameraPurchaseOKMessageEvent, onCameraPurchaseOKMessageEvent); + UseMessageEventHook(CameraPurchaseOKMessageEvent, onCameraPurchaseOKMessageEvent); const onCameraPublishStatusMessageEvent = useCallback((event: CameraPublishStatusMessageEvent) => { @@ -48,7 +48,7 @@ export const CameraWidgetCheckoutView: FC = props }); }, []); - CreateMessageHook(CameraPublishStatusMessageEvent, onCameraPublishStatusMessageEvent); + UseMessageEventHook(CameraPublishStatusMessageEvent, onCameraPublishStatusMessageEvent); const onCameraStorageUrlMessageEvent = useCallback((event: CameraStorageUrlMessageEvent) => { @@ -57,7 +57,7 @@ export const CameraWidgetCheckoutView: FC = props setPictureUrl(GetConfiguration('camera.url') + '/' + parser.url); }, []); - CreateMessageHook(CameraStorageUrlMessageEvent, onCameraStorageUrlMessageEvent); + UseMessageEventHook(CameraStorageUrlMessageEvent, onCameraStorageUrlMessageEvent); const processAction = (type: string, value: string | number = null) => { @@ -70,13 +70,13 @@ export const CameraWidgetCheckoutView: FC = props if(isWaiting) return; setIsWaiting(true); - SendMessageHook(new PurchasePhotoMessageComposer('')); + SendMessageComposer(new PurchasePhotoMessageComposer('')); return; case 'publish': if(isWaiting) return; setIsWaiting(true); - SendMessageHook(new PublishPhotoMessageComposer()); + SendMessageComposer(new PublishPhotoMessageComposer()); return; case 'cancel': onCancelClick(); @@ -127,7 +127,7 @@ export const CameraWidgetCheckoutView: FC = props { (picturesBought > 0) && { LocalizeText('camera.purchase.count.info') } { picturesBought } - dispatchUiEvent(new InventoryEvent(InventoryEvent.SHOW_INVENTORY)) }>{ LocalizeText('camera.open.inventory') } + DispatchUiEvent(new InventoryEvent(InventoryEvent.SHOW_INVENTORY)) }>{ LocalizeText('camera.open.inventory') } } diff --git a/src/components/catalog/CatalogMessageHandler.tsx b/src/components/catalog/CatalogMessageHandler.tsx index 831d6eff..ce829a33 100644 --- a/src/components/catalog/CatalogMessageHandler.tsx +++ b/src/components/catalog/CatalogMessageHandler.tsx @@ -2,13 +2,8 @@ import { ApproveNameMessageEvent, CatalogPageMessageEvent, CatalogPagesListEvent import { GuildMembershipsMessageEvent } from '@nitrots/nitro-renderer/src/nitro/communication/messages/incoming/user/GuildMembershipsMessageEvent'; import { FC, useCallback } from 'react'; import { GetFurnitureData, GetProductDataForLocalization, LocalizeText } from '../../api'; -import { CatalogNameResultEvent, CatalogPurchaseFailureEvent, CatalogPurchaseNotAllowedEvent, CatalogSetExtraPurchaseParameterEvent } from '../../events'; -import { CatalogGiftReceiverNotFoundEvent } from '../../events/catalog/CatalogGiftReceiverNotFoundEvent'; -import { CatalogPurchasedEvent } from '../../events/catalog/CatalogPurchasedEvent'; -import { CatalogPurchaseSoldOutEvent } from '../../events/catalog/CatalogPurchaseSoldOutEvent'; -import { BatchUpdates } from '../../hooks'; -import { dispatchUiEvent } from '../../hooks/events/ui/ui-event'; -import { CreateMessageHook } from '../../hooks/messages/message-event'; +import { CatalogGiftReceiverNotFoundEvent, CatalogNameResultEvent, CatalogPurchasedEvent, CatalogPurchaseFailureEvent, CatalogPurchaseNotAllowedEvent, CatalogPurchaseSoldOutEvent, CatalogSetExtraPurchaseParameterEvent } from '../../events'; +import { BatchUpdates, DispatchUiEvent, UseMessageEventHook } from '../../hooks'; import { NotificationAlertType } from '../../views/notification-center/common/NotificationAlertType'; import { NotificationUtilities } from '../../views/notification-center/common/NotificationUtilities'; import { useCatalogContext } from './CatalogContext'; @@ -102,28 +97,28 @@ export const CatalogMessageHandler: FC<{}> = props => { const parser = event.getParser(); - dispatchUiEvent(new CatalogPurchasedEvent(parser.offer)); + DispatchUiEvent(new CatalogPurchasedEvent(parser.offer)); }, []); const onPurchaseErrorMessageEvent = useCallback((event: PurchaseErrorMessageEvent) => { const parser = event.getParser(); - dispatchUiEvent(new CatalogPurchaseFailureEvent(parser.code)); + DispatchUiEvent(new CatalogPurchaseFailureEvent(parser.code)); }, []); const onPurchaseNotAllowedMessageEvent = useCallback((event: PurchaseNotAllowedMessageEvent) => { const parser = event.getParser(); - dispatchUiEvent(new CatalogPurchaseNotAllowedEvent(parser.code)); + DispatchUiEvent(new CatalogPurchaseNotAllowedEvent(parser.code)); }, []); const onLimitedEditionSoldOutEvent = useCallback((event: LimitedEditionSoldOutEvent) => { const parser = event.getParser(); - dispatchUiEvent(new CatalogPurchaseSoldOutEvent()); + DispatchUiEvent(new CatalogPurchaseSoldOutEvent()); }, []); const onProductOfferEvent = useCallback((event: ProductOfferEvent) => @@ -160,7 +155,7 @@ export const CatalogMessageHandler: FC<{}> = props => if(offer.product && (offer.product.productType === ProductTypeEnum.WALL)) { - dispatchUiEvent(new CatalogSetExtraPurchaseParameterEvent(offer.product.extraParam)); + DispatchUiEvent(new CatalogSetExtraPurchaseParameterEvent(offer.product.extraParam)); } // (this._isObjectMoverRequested) && (this._purchasableOffer) @@ -199,12 +194,12 @@ export const CatalogMessageHandler: FC<{}> = props => { const parser = event.getParser(); - dispatchUiEvent(new CatalogNameResultEvent(parser.result, parser.validationInfo)); + DispatchUiEvent(new CatalogNameResultEvent(parser.result, parser.validationInfo)); }, []); const onGiftReceiverNotFoundEvent = useCallback(() => { - dispatchUiEvent(new CatalogGiftReceiverNotFoundEvent()); + DispatchUiEvent(new CatalogGiftReceiverNotFoundEvent()); }, []); const onHabboClubOffersMessageEvent = useCallback((event: HabboClubOffersMessageEvent) => @@ -310,24 +305,24 @@ export const CatalogMessageHandler: FC<{}> = props => }); }, [ setCatalogOptions ]); - CreateMessageHook(CatalogPagesListEvent, onCatalogPagesListEvent); - CreateMessageHook(CatalogPageMessageEvent, onCatalogPageMessageEvent); - CreateMessageHook(PurchaseOKMessageEvent, onPurchaseOKMessageEvent); - CreateMessageHook(PurchaseErrorMessageEvent, onPurchaseErrorMessageEvent); - CreateMessageHook(PurchaseNotAllowedMessageEvent, onPurchaseNotAllowedMessageEvent); - CreateMessageHook(LimitedEditionSoldOutEvent, onLimitedEditionSoldOutEvent); - CreateMessageHook(ProductOfferEvent, onProductOfferEvent); - CreateMessageHook(GuildMembershipsMessageEvent, onGuildMembershipsMessageEvent); - CreateMessageHook(SellablePetPalettesMessageEvent, onSellablePetPalettesMessageEvent); - CreateMessageHook(ApproveNameMessageEvent, onApproveNameMessageEvent); - CreateMessageHook(GiftReceiverNotFoundEvent, onGiftReceiverNotFoundEvent); - CreateMessageHook(HabboClubOffersMessageEvent, onHabboClubOffersMessageEvent); - CreateMessageHook(UserSubscriptionEvent, onUserSubscriptionEvent); - CreateMessageHook(CatalogPublishedMessageEvent, onCatalogPublishedMessageEvent); - CreateMessageHook(GiftWrappingConfigurationEvent, onGiftWrappingConfigurationEvent); - CreateMessageHook(ClubGiftInfoEvent, onClubGiftInfoEvent); - CreateMessageHook(MarketplaceMakeOfferResult, onMarketplaceMakeOfferResult); - CreateMessageHook(MarketplaceConfigurationEvent, onMarketplaceConfigurationEvent); + UseMessageEventHook(CatalogPagesListEvent, onCatalogPagesListEvent); + UseMessageEventHook(CatalogPageMessageEvent, onCatalogPageMessageEvent); + UseMessageEventHook(PurchaseOKMessageEvent, onPurchaseOKMessageEvent); + UseMessageEventHook(PurchaseErrorMessageEvent, onPurchaseErrorMessageEvent); + UseMessageEventHook(PurchaseNotAllowedMessageEvent, onPurchaseNotAllowedMessageEvent); + UseMessageEventHook(LimitedEditionSoldOutEvent, onLimitedEditionSoldOutEvent); + UseMessageEventHook(ProductOfferEvent, onProductOfferEvent); + UseMessageEventHook(GuildMembershipsMessageEvent, onGuildMembershipsMessageEvent); + UseMessageEventHook(SellablePetPalettesMessageEvent, onSellablePetPalettesMessageEvent); + UseMessageEventHook(ApproveNameMessageEvent, onApproveNameMessageEvent); + UseMessageEventHook(GiftReceiverNotFoundEvent, onGiftReceiverNotFoundEvent); + UseMessageEventHook(HabboClubOffersMessageEvent, onHabboClubOffersMessageEvent); + UseMessageEventHook(UserSubscriptionEvent, onUserSubscriptionEvent); + UseMessageEventHook(CatalogPublishedMessageEvent, onCatalogPublishedMessageEvent); + UseMessageEventHook(GiftWrappingConfigurationEvent, onGiftWrappingConfigurationEvent); + UseMessageEventHook(ClubGiftInfoEvent, onClubGiftInfoEvent); + UseMessageEventHook(MarketplaceMakeOfferResult, onMarketplaceMakeOfferResult); + UseMessageEventHook(MarketplaceConfigurationEvent, onMarketplaceConfigurationEvent); return null; } diff --git a/src/components/catalog/CatalogView.tsx b/src/components/catalog/CatalogView.tsx index b7af4ae9..36a5979a 100644 --- a/src/components/catalog/CatalogView.tsx +++ b/src/components/catalog/CatalogView.tsx @@ -1,14 +1,9 @@ import { FrontPageItem, GetCatalogIndexComposer, GetCatalogPageComposer, GetClubGiftInfo, GetGiftWrappingConfigurationComposer, GetMarketplaceConfigurationMessageComposer, ILinkEventTracker, RoomPreviewer } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; -import { AddEventLinkTracker, GetRoomEngine, LocalizeText, RemoveLinkEventTracker } from '../../api'; -import { CREDITS, PlaySound } from '../../api/utils/PlaySound'; -import { NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../common'; -import { Column } from '../../common/Column'; -import { Grid } from '../../common/Grid'; +import { AddEventLinkTracker, CREDITS, GetRoomEngine, LocalizeText, PlaySound, RemoveLinkEventTracker, SendMessageComposer } from '../../api'; +import { Column, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../common'; import { CatalogPurchasedEvent } from '../../events'; -import { BatchUpdates } from '../../hooks'; -import { useUiEvent } from '../../hooks/events/ui/ui-event'; -import { SendMessageHook } from '../../hooks/messages/message-event'; +import { BatchUpdates, UseUiEvent } from '../../hooks'; import { CatalogContextProvider } from './CatalogContext'; import { CatalogMessageHandler } from './CatalogMessageHandler'; import { CatalogPage } from './common/CatalogPage'; @@ -119,7 +114,7 @@ export const CatalogView: FC<{}> = props => setPageId(pageId); }); - if(pageId > -1) SendMessageHook(new GetCatalogPageComposer(pageId, offerId, currentType)); + if(pageId > -1) SendMessageComposer(new GetCatalogPageComposer(pageId, offerId, currentType)); }, [ currentType ]); const showCatalogPage = useCallback((pageId: number, layoutCode: string, localization: IPageLocalization, offers: IPurchasableOffer[], offerId: number, acceptSeasonCurrencyAsCredits: boolean) => @@ -276,7 +271,7 @@ export const CatalogView: FC<{}> = props => PlaySound(CREDITS); }, []); - useUiEvent(CatalogPurchasedEvent.PURCHASE_SUCCESS, onCatalogPurchasedEvent); + UseUiEvent(CatalogPurchasedEvent.PURCHASE_SUCCESS, onCatalogPurchasedEvent); const linkReceived = useCallback((url: string) => { @@ -352,10 +347,10 @@ export const CatalogView: FC<{}> = props => { if(!isVisible || rootNode) return; - SendMessageHook(new GetMarketplaceConfigurationMessageComposer()); - SendMessageHook(new GetGiftWrappingConfigurationComposer()); - SendMessageHook(new GetClubGiftInfo()); - SendMessageHook(new GetCatalogIndexComposer(currentType)); + SendMessageComposer(new GetMarketplaceConfigurationMessageComposer()); + SendMessageComposer(new GetGiftWrappingConfigurationComposer()); + SendMessageComposer(new GetClubGiftInfo()); + SendMessageComposer(new GetCatalogIndexComposer(currentType)); }, [ isVisible, rootNode, currentType ]); useEffect(() => diff --git a/src/components/catalog/common/FurnitureOffer.ts b/src/components/catalog/common/FurnitureOffer.ts index 9197ae9f..b25c376f 100644 --- a/src/components/catalog/common/FurnitureOffer.ts +++ b/src/components/catalog/common/FurnitureOffer.ts @@ -1,6 +1,5 @@ import { GetProductOfferComposer, IFurnitureData } from '@nitrots/nitro-renderer'; -import { GetProductDataForLocalization } from '../../../api'; -import { SendMessageHook } from '../../../hooks'; +import { GetProductDataForLocalization, SendMessageComposer } from '../../../api'; import { ICatalogPage } from './ICatalogPage'; import { IProduct } from './IProduct'; import { IPurchasableOffer } from './IPurchasableOffer'; @@ -21,7 +20,7 @@ export class FurnitureOffer implements IPurchasableOffer public activate(): void { - SendMessageHook(new GetProductOfferComposer((this._furniData.rentOfferId > -1) ? this._furniData.rentOfferId : this._furniData.purchaseOfferId)); + SendMessageComposer(new GetProductOfferComposer((this._furniData.rentOfferId > -1) ? this._furniData.rentOfferId : this._furniData.purchaseOfferId)); } public get offerId(): number diff --git a/src/components/catalog/views/catalog-room-previewer/CatalogRoomPreviewerView.tsx b/src/components/catalog/views/catalog-room-previewer/CatalogRoomPreviewerView.tsx index 75b472bf..89e7f5ea 100644 --- a/src/components/catalog/views/catalog-room-previewer/CatalogRoomPreviewerView.tsx +++ b/src/components/catalog/views/catalog-room-previewer/CatalogRoomPreviewerView.tsx @@ -2,7 +2,7 @@ import { NitroToolbarAnimateIconEvent, TextureUtils, ToolbarIconEnum } from '@ni import { FC, useCallback, useRef } from 'react'; import { GetRoomEngine } from '../../../../api'; import { CatalogPurchasedEvent } from '../../../../events'; -import { useUiEvent } from '../../../../hooks'; +import { UseUiEvent } from '../../../../hooks'; import { RoomPreviewerView, RoomPreviewerViewProps } from '../../../../views/shared/room-previewer/RoomPreviewerView'; export const CatalogRoomPreviewerView: FC = props => @@ -39,7 +39,7 @@ export const CatalogRoomPreviewerView: FC = props => animatePurchase(); }, [ animatePurchase ]); - useUiEvent(CatalogPurchasedEvent.PURCHASE_SUCCESS, onCatalogPurchasedEvent); + UseUiEvent(CatalogPurchasedEvent.PURCHASE_SUCCESS, onCatalogPurchasedEvent); return (
diff --git a/src/components/catalog/views/gift/CatalogGiftView.tsx b/src/components/catalog/views/gift/CatalogGiftView.tsx index 760f6260..dc7442af 100644 --- a/src/components/catalog/views/gift/CatalogGiftView.tsx +++ b/src/components/catalog/views/gift/CatalogGiftView.tsx @@ -2,11 +2,11 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { PurchaseFromCatalogAsGiftComposer } from '@nitrots/nitro-renderer'; import classNames from 'classnames'; import { FC, useCallback, useEffect, useMemo, useState } from 'react'; -import { GetSessionDataManager, LocalizeText } from '../../../../api'; +import { GetSessionDataManager, LocalizeText, SendMessageComposer } from '../../../../api'; import { Base, Button, ButtonGroup, Column, Flex, FormGroup, LayoutGiftTagView, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../../common'; import { CatalogEvent, CatalogPurchasedEvent } from '../../../../events'; import { CatalogInitGiftEvent } from '../../../../events/catalog/CatalogInitGiftEvent'; -import { BatchUpdates, SendMessageHook, useUiEvent } from '../../../../hooks'; +import { BatchUpdates, UseUiEvent } from '../../../../hooks'; import { CurrencyIcon } from '../../../../views/shared/currency-icon/CurrencyIcon'; import { FurniImageView } from '../../../../views/shared/furni-image/FurniImageView'; import { useCatalogContext } from '../../CatalogContext'; @@ -75,9 +75,9 @@ export const CatalogGiftView: FC<{}> = props => } }, [ close ]); - useUiEvent(CatalogPurchasedEvent.PURCHASE_SUCCESS, onCatalogEvent); - useUiEvent(CatalogEvent.INIT_GIFT, onCatalogEvent); - useUiEvent(CatalogEvent.GIFT_RECEIVER_NOT_FOUND, onCatalogEvent); + UseUiEvent(CatalogPurchasedEvent.PURCHASE_SUCCESS, onCatalogEvent); + UseUiEvent(CatalogEvent.INIT_GIFT, onCatalogEvent); + UseUiEvent(CatalogEvent.GIFT_RECEIVER_NOT_FOUND, onCatalogEvent); const isBoxDefault = useMemo(() => { @@ -123,7 +123,7 @@ export const CatalogGiftView: FC<{}> = props => return; } - SendMessageHook(new PurchaseFromCatalogAsGiftComposer(pageId, offerId, extraData, receiverName, message, selectedColorId, selectedBoxIndex, selectedRibbonIndex, showMyFace)); + SendMessageComposer(new PurchaseFromCatalogAsGiftComposer(pageId, offerId, extraData, receiverName, message, selectedColorId, selectedBoxIndex, selectedRibbonIndex, showMyFace)); return; } }, [ extraData, maxBoxIndex, maxRibbonIndex, message, offerId, pageId, receiverName, selectedBoxIndex, selectedColorId, selectedRibbonIndex, showMyFace ]); diff --git a/src/components/catalog/views/page/common/CatalogRedeemVoucherView.tsx b/src/components/catalog/views/page/common/CatalogRedeemVoucherView.tsx index 2e3a97fa..472e4762 100644 --- a/src/components/catalog/views/page/common/CatalogRedeemVoucherView.tsx +++ b/src/components/catalog/views/page/common/CatalogRedeemVoucherView.tsx @@ -1,10 +1,9 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { RedeemVoucherMessageComposer, VoucherRedeemErrorMessageEvent, VoucherRedeemOkMessageEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useState } from 'react'; -import { LocalizeText } from '../../../../../api'; -import { Button } from '../../../../../common/Button'; -import { Flex } from '../../../../../common/Flex'; -import { BatchUpdates, CreateMessageHook, SendMessageHook } from '../../../../../hooks'; +import { LocalizeText, SendMessageComposer } from '../../../../../api'; +import { Button, Flex } from '../../../../../common'; +import { BatchUpdates, UseMessageEventHook } from '../../../../../hooks'; import { NotificationUtilities } from '../../../../../views/notification-center/common/NotificationUtilities'; export interface CatalogRedeemVoucherViewProps @@ -22,7 +21,7 @@ export const CatalogRedeemVoucherView: FC = props { if(!voucher || !voucher.length || isWaiting) return; - SendMessageHook(new RedeemVoucherMessageComposer(voucher)); + SendMessageComposer(new RedeemVoucherMessageComposer(voucher)); setIsWaiting(true); } @@ -44,7 +43,7 @@ export const CatalogRedeemVoucherView: FC = props }); }, []); - CreateMessageHook(VoucherRedeemOkMessageEvent, onVoucherRedeemOkMessageEvent); + UseMessageEventHook(VoucherRedeemOkMessageEvent, onVoucherRedeemOkMessageEvent); const onVoucherRedeemErrorMessageEvent = useCallback((event: VoucherRedeemErrorMessageEvent) => { @@ -55,7 +54,7 @@ export const CatalogRedeemVoucherView: FC = props setIsWaiting(false); }, []); - CreateMessageHook(VoucherRedeemErrorMessageEvent, onVoucherRedeemErrorMessageEvent); + UseMessageEventHook(VoucherRedeemErrorMessageEvent, onVoucherRedeemErrorMessageEvent); return ( diff --git a/src/components/catalog/views/page/layout/CatalogLayoutGuildForumView.tsx b/src/components/catalog/views/page/layout/CatalogLayoutGuildForumView.tsx index f04a3822..2e63e14d 100644 --- a/src/components/catalog/views/page/layout/CatalogLayoutGuildForumView.tsx +++ b/src/components/catalog/views/page/layout/CatalogLayoutGuildForumView.tsx @@ -1,11 +1,7 @@ import { CatalogGroupsComposer } from '@nitrots/nitro-renderer'; import { FC, useEffect, useState } from 'react'; -import { Base } from '../../../../../common/Base'; -import { Column } from '../../../../../common/Column'; -import { Flex } from '../../../../../common/Flex'; -import { Grid } from '../../../../../common/Grid'; -import { Text } from '../../../../../common/Text'; -import { SendMessageHook } from '../../../../../hooks/messages'; +import { SendMessageComposer } from '../../../../../api'; +import { Base, Column, Flex, Grid, Text } from '../../../../../common'; import { useCatalogContext } from '../../../CatalogContext'; import { CatalogFirstProductSelectorWidgetView } from '../widgets/CatalogFirstProductSelectorWidgetView'; import { CatalogGuildSelectorWidgetView } from '../widgets/CatalogGuildSelectorWidgetView'; @@ -22,7 +18,7 @@ export const CatalogLayouGuildForumView: FC = props => useEffect(() => { - SendMessageHook(new CatalogGroupsComposer()); + SendMessageComposer(new CatalogGroupsComposer()); }, [ page ]); return ( diff --git a/src/components/catalog/views/page/layout/CatalogLayoutVipBuyView.tsx b/src/components/catalog/views/page/layout/CatalogLayoutVipBuyView.tsx index b834d03c..c9fb1e68 100644 --- a/src/components/catalog/views/page/layout/CatalogLayoutVipBuyView.tsx +++ b/src/components/catalog/views/page/layout/CatalogLayoutVipBuyView.tsx @@ -1,18 +1,9 @@ import { ClubOfferData, GetClubOffersMessageComposer, PurchaseFromCatalogComposer } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useMemo, useState } from 'react'; -import { LocalizeText } from '../../../../../api'; -import { AutoGrid } from '../../../../../common/AutoGrid'; -import { Button } from '../../../../../common/Button'; -import { Column } from '../../../../../common/Column'; -import { Flex } from '../../../../../common/Flex'; -import { Grid } from '../../../../../common/Grid'; -import { LayoutGridItem } from '../../../../../common/layout/LayoutGridItem'; -import { LayoutLoadingSpinnerView } from '../../../../../common/layout/LayoutLoadingSpinnerView'; -import { Text } from '../../../../../common/Text'; -import { CatalogPurchasedEvent, CatalogPurchaseFailureEvent } from '../../../../../events'; -import { CatalogEvent } from '../../../../../events/catalog/CatalogEvent'; -import { useUiEvent } from '../../../../../hooks'; -import { SendMessageHook } from '../../../../../hooks/messages/message-event'; +import { LocalizeText, SendMessageComposer } from '../../../../../api'; +import { AutoGrid, Button, Column, Flex, Grid, LayoutGridItem, LayoutLoadingSpinnerView, Text } from '../../../../../common'; +import { CatalogEvent, CatalogPurchasedEvent, CatalogPurchaseFailureEvent } from '../../../../../events'; +import { UseUiEvent } from '../../../../../hooks'; import { CurrencyIcon } from '../../../../../views/shared/currency-icon/CurrencyIcon'; import { GetCurrencyAmount } from '../../../../purse/common/CurrencyHelper'; import { GLOBAL_PURSE } from '../../../../purse/PurseView'; @@ -40,8 +31,8 @@ export const CatalogLayoutVipBuyView: FC = props => } }, []); - useUiEvent(CatalogPurchasedEvent.PURCHASE_SUCCESS, onCatalogEvent); - useUiEvent(CatalogPurchaseFailureEvent.PURCHASE_FAILED, onCatalogEvent); + UseUiEvent(CatalogPurchasedEvent.PURCHASE_SUCCESS, onCatalogEvent); + UseUiEvent(CatalogPurchaseFailureEvent.PURCHASE_FAILED, onCatalogEvent); const getOfferText = useCallback((offer: ClubOfferData) => { @@ -103,7 +94,7 @@ export const CatalogLayoutVipBuyView: FC = props => if(!pendingOffer) return; setPurchaseState(CatalogPurchaseState.PURCHASE); - SendMessageHook(new PurchaseFromCatalogComposer(currentPage.pageId, pendingOffer.offerId, null, 1)); + SendMessageComposer(new PurchaseFromCatalogComposer(currentPage.pageId, pendingOffer.offerId, null, 1)); }, [ pendingOffer, currentPage ]); const setOffer = useCallback((offer: ClubOfferData) => @@ -142,7 +133,7 @@ export const CatalogLayoutVipBuyView: FC = props => useEffect(() => { - if(!clubOffers) SendMessageHook(new GetClubOffersMessageComposer(1)); + if(!clubOffers) SendMessageComposer(new GetClubOffersMessageComposer(1)); }, [ clubOffers ]); return ( diff --git a/src/components/catalog/views/page/layout/marketplace/CatalogLayoutMarketplaceOwnItemsView.tsx b/src/components/catalog/views/page/layout/marketplace/CatalogLayoutMarketplaceOwnItemsView.tsx index 22ee1f34..910389e0 100644 --- a/src/components/catalog/views/page/layout/marketplace/CatalogLayoutMarketplaceOwnItemsView.tsx +++ b/src/components/catalog/views/page/layout/marketplace/CatalogLayoutMarketplaceOwnItemsView.tsx @@ -1,11 +1,8 @@ import { CancelMarketplaceOfferMessageComposer, GetMarketplaceOwnOffersMessageComposer, MarketplaceCancelOfferResultEvent, MarketplaceOwnOffersEvent, RedeemMarketplaceOfferCreditsMessageComposer } from '@nitrots/nitro-renderer'; import { FC, useCallback, useMemo, useState } from 'react'; -import { LocalizeText } from '../../../../../../api'; -import { Button } from '../../../../../../common/Button'; -import { Column } from '../../../../../../common/Column'; -import { Grid } from '../../../../../../common/Grid'; -import { Text } from '../../../../../../common/Text'; -import { BatchUpdates, CreateMessageHook, SendMessageHook, UseMountEffect } from '../../../../../../hooks'; +import { LocalizeText, SendMessageComposer } from '../../../../../../api'; +import { Button, Column, Grid, Text } from '../../../../../../common'; +import { BatchUpdates, UseMessageEventHook, UseMountEffect } from '../../../../../../hooks'; import { NotificationAlertType } from '../../../../../../views/notification-center/common/NotificationAlertType'; import { NotificationUtilities } from '../../../../../../views/notification-center/common/NotificationUtilities'; import { CatalogLayoutProps } from '../CatalogLayout.types'; @@ -40,7 +37,7 @@ export const CatalogLayoutMarketplaceOwnItemsView: FC = prop }); }, []); - CreateMessageHook(MarketplaceOwnOffersEvent, onMarketPlaceOwnOffersEvent); + UseMessageEventHook(MarketplaceOwnOffersEvent, onMarketPlaceOwnOffersEvent); const onMarketplaceCancelOfferResultEvent = useCallback((event:MarketplaceCancelOfferResultEvent) => { @@ -58,7 +55,7 @@ export const CatalogLayoutMarketplaceOwnItemsView: FC = prop setOffers(prevValue => prevValue.filter(value => (value.offerId !== parser.offerId))); }, []); - CreateMessageHook(MarketplaceCancelOfferResultEvent, onMarketplaceCancelOfferResultEvent); + UseMessageEventHook(MarketplaceCancelOfferResultEvent, onMarketplaceCancelOfferResultEvent); const soldOffers = useMemo(() => { @@ -74,17 +71,17 @@ export const CatalogLayoutMarketplaceOwnItemsView: FC = prop return prevValue.filter(value => (idsToDelete.indexOf(value.offerId) === -1)); }) - SendMessageHook(new RedeemMarketplaceOfferCreditsMessageComposer()); + SendMessageComposer(new RedeemMarketplaceOfferCreditsMessageComposer()); }, [ soldOffers ]); const takeItemBack = (offerData: MarketplaceOfferData) => { - SendMessageHook(new CancelMarketplaceOfferMessageComposer(offerData.offerId)); + SendMessageComposer(new CancelMarketplaceOfferMessageComposer(offerData.offerId)); }; UseMountEffect(() => { - SendMessageHook(new GetMarketplaceOwnOffersMessageComposer()); + SendMessageComposer(new GetMarketplaceOwnOffersMessageComposer()); }); return ( diff --git a/src/components/catalog/views/page/layout/marketplace/CatalogLayoutMarketplacePublicItemsView.tsx b/src/components/catalog/views/page/layout/marketplace/CatalogLayoutMarketplacePublicItemsView.tsx index 4a4f4fb9..c4f72c9b 100644 --- a/src/components/catalog/views/page/layout/marketplace/CatalogLayoutMarketplacePublicItemsView.tsx +++ b/src/components/catalog/views/page/layout/marketplace/CatalogLayoutMarketplacePublicItemsView.tsx @@ -1,12 +1,8 @@ import { BuyMarketplaceOfferMessageComposer, GetMarketplaceOffersMessageComposer, MarketplaceBuyOfferResultEvent, MarketPlaceOffersEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useMemo, useState } from 'react'; -import { LocalizeText } from '../../../../../../api'; -import { Button } from '../../../../../../common/Button'; -import { ButtonGroup } from '../../../../../../common/ButtonGroup'; -import { Column } from '../../../../../../common/Column'; -import { Grid } from '../../../../../../common/Grid'; -import { Text } from '../../../../../../common/Text'; -import { BatchUpdates, CreateMessageHook, SendMessageHook } from '../../../../../../hooks'; +import { LocalizeText, SendMessageComposer } from '../../../../../../api'; +import { Button, ButtonGroup, Column, Grid, Text } from '../../../../../../common'; +import { BatchUpdates, UseMessageEventHook } from '../../../../../../hooks'; import { NotificationAlertType } from '../../../../../../views/notification-center/common/NotificationAlertType'; import { NotificationUtilities } from '../../../../../../views/notification-center/common/NotificationUtilities'; import { GetCurrencyAmount } from '../../../../../purse/common/CurrencyHelper'; @@ -35,7 +31,7 @@ export const CatalogLayoutMarketplacePublicItemsView: FC { setLastSearch(options); - SendMessageHook(new GetMarketplaceOffersMessageComposer(options.minPrice, options.maxPrice, options.query, options.type)) + SendMessageComposer(new GetMarketplaceOffersMessageComposer(options.minPrice, options.maxPrice, options.query, options.type)) }, []); const getSortTypes = useMemo( () => @@ -62,7 +58,7 @@ export const CatalogLayoutMarketplacePublicItemsView: FC { - SendMessageHook(new BuyMarketplaceOfferMessageComposer(offerId)); + SendMessageComposer(new BuyMarketplaceOfferMessageComposer(offerId)); }, null, null, null, LocalizeText('catalog.marketplace.confirm_title')); },[]); @@ -132,7 +128,7 @@ export const CatalogLayoutMarketplacePublicItemsView: FC { - SendMessageHook(new BuyMarketplaceOfferMessageComposer(parser.offerId)); + SendMessageComposer(new BuyMarketplaceOfferMessageComposer(parser.offerId)); }, null, null, null, LocalizeText('catalog.marketplace.confirm_higher_title')); break; @@ -142,8 +138,8 @@ export const CatalogLayoutMarketplacePublicItemsView: FC diff --git a/src/components/catalog/views/page/layout/marketplace/MarketplacePostOfferView.tsx b/src/components/catalog/views/page/layout/marketplace/MarketplacePostOfferView.tsx index 31e414c0..9ba734f8 100644 --- a/src/components/catalog/views/page/layout/marketplace/MarketplacePostOfferView.tsx +++ b/src/components/catalog/views/page/layout/marketplace/MarketplacePostOfferView.tsx @@ -1,9 +1,9 @@ import { ImageResult, MakeOfferMessageComposer, Vector3d } from '@nitrots/nitro-renderer'; import { FC, useCallback, useState } from 'react'; -import { GetRoomEngine, LocalizeText } from '../../../../../../api'; +import { GetRoomEngine, LocalizeText, SendMessageComposer } from '../../../../../../api'; import { Base, Button, Column, Grid, LayoutImage, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../../../../common'; import { CatalogPostMarketplaceOfferEvent } from '../../../../../../events'; -import { BatchUpdates, SendMessageHook, useUiEvent } from '../../../../../../hooks'; +import { BatchUpdates, UseUiEvent } from '../../../../../../hooks'; import { NotificationUtilities } from '../../../../../../views/notification-center/common/NotificationUtilities'; import { FurnitureItem } from '../../../../../inventory/common/FurnitureItem'; import { useCatalogContext } from '../../../../CatalogContext'; @@ -29,7 +29,7 @@ export const MarketplacePostOfferView : FC<{}> = props => setItem(event.item); }, []); - useUiEvent(CatalogPostMarketplaceOfferEvent.POST_MARKETPLACE, onCatalogPostMarketplaceOfferEvent); + UseUiEvent(CatalogPostMarketplaceOfferEvent.POST_MARKETPLACE, onCatalogPostMarketplaceOfferEvent); const getItemImage = useCallback( () => { @@ -79,7 +79,7 @@ export const MarketplacePostOfferView : FC<{}> = props => NotificationUtilities.confirm(LocalizeText('inventory.marketplace.confirm_offer.info', ['furniname', 'price'], [getFurniTitle(), askingPrice.toString()]), () => { - SendMessageHook(new MakeOfferMessageComposer(askingPrice, item.isWallItem ? 2 : 1, item.id)); + SendMessageComposer(new MakeOfferMessageComposer(askingPrice, item.isWallItem ? 2 : 1, item.id)); setItem(null); }, () => { setItem(null)}, null, null, LocalizeText('inventory.marketplace.confirm_offer.title')); diff --git a/src/components/catalog/views/page/layout/pets/CatalogLayoutPetPurchaseView.tsx b/src/components/catalog/views/page/layout/pets/CatalogLayoutPetPurchaseView.tsx index 48977451..be5caf39 100644 --- a/src/components/catalog/views/page/layout/pets/CatalogLayoutPetPurchaseView.tsx +++ b/src/components/catalog/views/page/layout/pets/CatalogLayoutPetPurchaseView.tsx @@ -1,12 +1,9 @@ import { ApproveNameMessageComposer } from '@nitrots/nitro-renderer'; import { FC, useCallback, useState } from 'react'; -import { LocalizeText } from '../../../../../../api'; -import { Column } from '../../../../../../common/Column'; -import { Flex } from '../../../../../../common/Flex'; -import { Text } from '../../../../../../common/Text'; +import { LocalizeText, SendMessageComposer } from '../../../../../../api'; +import { Column, Flex, Text } from '../../../../../../common'; import { CatalogPurchasedEvent } from '../../../../../../events'; -import { useUiEvent } from '../../../../../../hooks/events/ui/ui-event'; -import { SendMessageHook } from '../../../../../../hooks/messages/message-event'; +import { UseUiEvent } from '../../../../../../hooks'; import { CurrencyIcon } from '../../../../../../views/shared/currency-icon/CurrencyIcon'; import { IPurchasableOffer } from '../../../../common/IPurchasableOffer'; import { Offer } from '../../../../common/Offer'; @@ -31,11 +28,11 @@ export const CatalogLayoutPetPurchaseView: FC setNameApproved(false); }, []); - useUiEvent(CatalogPurchasedEvent.PURCHASE_SUCCESS, onCatalogPurchasedEvent); + UseUiEvent(CatalogPurchasedEvent.PURCHASE_SUCCESS, onCatalogPurchasedEvent); const beforePurchase = useCallback(() => { - SendMessageHook(new ApproveNameMessageComposer(petNameValue, 1)); + SendMessageComposer(new ApproveNameMessageComposer(petNameValue, 1)); }, [ petNameValue ]); const extraData = `${ petNameValue }\n${ extra }`; diff --git a/src/components/catalog/views/page/layout/pets/CatalogLayoutPetView.tsx b/src/components/catalog/views/page/layout/pets/CatalogLayoutPetView.tsx index 6b35eba7..4d215caf 100644 --- a/src/components/catalog/views/page/layout/pets/CatalogLayoutPetView.tsx +++ b/src/components/catalog/views/page/layout/pets/CatalogLayoutPetView.tsx @@ -1,19 +1,10 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { ApproveNameMessageComposer, ColorConverter, GetSellablePetPalettesComposer, PurchaseFromCatalogComposer, SellablePetPaletteData } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useMemo, useState } from 'react'; -import { LocalizeText } from '../../../../../../api'; -import { AutoGrid } from '../../../../../../common/AutoGrid'; -import { Base } from '../../../../../../common/Base'; -import { Button } from '../../../../../../common/Button'; -import { Column } from '../../../../../../common/Column'; -import { Flex } from '../../../../../../common/Flex'; -import { Grid } from '../../../../../../common/Grid'; -import { LayoutGridItem } from '../../../../../../common/layout/LayoutGridItem'; -import { Text } from '../../../../../../common/Text'; -import { CatalogNameResultEvent, CatalogPurchaseFailureEvent } from '../../../../../../events'; -import { CatalogWidgetEvent } from '../../../../../../events/catalog/CatalogWidgetEvent'; -import { BatchUpdates, dispatchUiEvent, useUiEvent } from '../../../../../../hooks'; -import { SendMessageHook } from '../../../../../../hooks/messages/message-event'; +import { LocalizeText, SendMessageComposer } from '../../../../../../api'; +import { AutoGrid, Base, Button, Column, Flex, Grid, LayoutGridItem, Text } from '../../../../../../common'; +import { CatalogNameResultEvent, CatalogPurchaseFailureEvent, CatalogWidgetEvent } from '../../../../../../events'; +import { BatchUpdates, DispatchUiEvent, UseUiEvent } from '../../../../../../hooks'; import { PetImageView } from '../../../../../../views/shared/pet-image/PetImageView'; import { useCatalogContext } from '../../../../CatalogContext'; import { GetPetAvailableColors, GetPetIndexFromLocalization } from '../../../../common/CatalogUtilities'; @@ -103,14 +94,14 @@ export const CatalogLayoutPetView: FC = props => { if(approvalResult === -1) { - SendMessageHook(new ApproveNameMessageComposer(petName, 1)); + SendMessageComposer(new ApproveNameMessageComposer(petName, 1)); return; } if(approvalResult === 0) { - SendMessageHook(new PurchaseFromCatalogComposer(page.pageId, currentOffer.offerId, `${ petName }\n${ petPurchaseString }`, 1)); + SendMessageComposer(new PurchaseFromCatalogComposer(page.pageId, currentOffer.offerId, `${ petName }\n${ petPurchaseString }`, 1)); return; } @@ -121,10 +112,10 @@ export const CatalogLayoutPetView: FC = props => setApprovalResult(event.result); if(event.result === 0) purchasePet(); - else dispatchUiEvent(new CatalogPurchaseFailureEvent(-1)); + else DispatchUiEvent(new CatalogPurchaseFailureEvent(-1)); }, [ purchasePet ]); - useUiEvent(CatalogWidgetEvent.APPROVE_RESULT, onCatalogNameResultEvent); + UseUiEvent(CatalogWidgetEvent.APPROVE_RESULT, onCatalogNameResultEvent); useEffect(() => { @@ -176,7 +167,7 @@ export const CatalogLayoutPetView: FC = props => setSellablePalettes([]); }); - SendMessageHook(new GetSellablePetPalettesComposer(productData.type)); + SendMessageComposer(new GetSellablePetPalettesComposer(productData.type)); }, [ currentOffer, petPalettes ]); useEffect(() => diff --git a/src/components/catalog/views/page/layout/pets/CatalogPetNameApprovalView.tsx b/src/components/catalog/views/page/layout/pets/CatalogPetNameApprovalView.tsx index 22d863b7..ca22262d 100644 --- a/src/components/catalog/views/page/layout/pets/CatalogPetNameApprovalView.tsx +++ b/src/components/catalog/views/page/layout/pets/CatalogPetNameApprovalView.tsx @@ -1,7 +1,7 @@ import { Dispatch, FC, SetStateAction, useCallback, useEffect, useState } from 'react'; import { LocalizeText } from '../../../../../../api'; import { CatalogEvent, CatalogNameResultEvent } from '../../../../../../events'; -import { useUiEvent } from '../../../../../../hooks/events/ui/ui-event'; +import { UseUiEvent } from '../../../../../../hooks'; export interface CatalogPetNameApprovalViewProps { @@ -28,7 +28,7 @@ export const CatalogPetNameApprovalView: FC = p setValidationResult(event.result); }, [ setNameApproved ]); - useUiEvent(CatalogEvent.APPROVE_NAME_RESULT, onCatalogNameResultEvent); + UseUiEvent(CatalogEvent.APPROVE_NAME_RESULT, onCatalogNameResultEvent); const validationErrorMessage = () => { diff --git a/src/components/catalog/views/page/layout/vip-gifts/CatalogLayoutVipGiftsView.tsx b/src/components/catalog/views/page/layout/vip-gifts/CatalogLayoutVipGiftsView.tsx index d9ca1e9a..dc44f975 100644 --- a/src/components/catalog/views/page/layout/vip-gifts/CatalogLayoutVipGiftsView.tsx +++ b/src/components/catalog/views/page/layout/vip-gifts/CatalogLayoutVipGiftsView.tsx @@ -1,9 +1,7 @@ import { SelectClubGiftComposer } from '@nitrots/nitro-renderer'; import { FC, useCallback } from 'react'; -import { LocalizeText } from '../../../../../../api'; -import { AutoGrid } from '../../../../../../common/AutoGrid'; -import { Text } from '../../../../../../common/Text'; -import { SendMessageHook } from '../../../../../../hooks'; +import { LocalizeText, SendMessageComposer } from '../../../../../../api'; +import { AutoGrid, Text } from '../../../../../../common'; import { NotificationUtilities } from '../../../../../../views/notification-center/common/NotificationUtilities'; import { useCatalogContext } from '../../../../CatalogContext'; import { CatalogLayoutProps } from '../CatalogLayout.types'; @@ -31,7 +29,7 @@ export const CatalogLayoutVipGiftsView: FC = props => { NotificationUtilities.confirm(LocalizeText('catalog.club_gift.confirm'), () => { - SendMessageHook(new SelectClubGiftComposer(localizationId)); + SendMessageComposer(new SelectClubGiftComposer(localizationId)); setCatalogOptions(prevValue => { diff --git a/src/components/catalog/views/page/widgets/CatalogBadgeSelectorWidgetView.tsx b/src/components/catalog/views/page/widgets/CatalogBadgeSelectorWidgetView.tsx index b6bbbf76..6d681655 100644 --- a/src/components/catalog/views/page/widgets/CatalogBadgeSelectorWidgetView.tsx +++ b/src/components/catalog/views/page/widgets/CatalogBadgeSelectorWidgetView.tsx @@ -1,10 +1,8 @@ import { StringDataType } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useMemo, useState } from 'react'; -import { AutoGrid, AutoGridProps } from '../../../../../common/AutoGrid'; -import { LayoutGridItem } from '../../../../../common/layout/LayoutGridItem'; -import { InventoryBadgesUpdatedEvent } from '../../../../../events'; -import { InventoryBadgesRequestEvent } from '../../../../../events/inventory/InventoryBadgesRequestEvent'; -import { dispatchUiEvent, useUiEvent } from '../../../../../hooks'; +import { AutoGrid, AutoGridProps, LayoutGridItem } from '../../../../../common'; +import { InventoryBadgesRequestEvent, InventoryBadgesUpdatedEvent } from '../../../../../events'; +import { DispatchUiEvent, UseUiEvent } from '../../../../../hooks'; import { BadgeImageView } from '../../../../../views/shared/badge-image/BadgeImageView'; import { useCatalogContext } from '../../../CatalogContext'; @@ -27,7 +25,7 @@ export const CatalogBadgeSelectorWidgetView: FC { @@ -55,7 +53,7 @@ export const CatalogBadgeSelectorWidgetView: FC { - dispatchUiEvent(new InventoryBadgesRequestEvent(InventoryBadgesRequestEvent.REQUEST_BADGES)); + DispatchUiEvent(new InventoryBadgesRequestEvent(InventoryBadgesRequestEvent.REQUEST_BADGES)); }, []); return ( diff --git a/src/components/catalog/views/page/widgets/CatalogGuildBadgeWidgetView.tsx b/src/components/catalog/views/page/widgets/CatalogGuildBadgeWidgetView.tsx index b1dce9b6..0bbbe517 100644 --- a/src/components/catalog/views/page/widgets/CatalogGuildBadgeWidgetView.tsx +++ b/src/components/catalog/views/page/widgets/CatalogGuildBadgeWidgetView.tsx @@ -1,6 +1,6 @@ import { StringDataType } from '@nitrots/nitro-renderer'; import { FC, useMemo } from 'react'; -import { BaseProps } from '../../../../../common/Base'; +import { BaseProps } from '../../../../../common'; import { BadgeImageView } from '../../../../../views/shared/badge-image/BadgeImageView'; import { useCatalogContext } from '../../../CatalogContext'; diff --git a/src/components/catalog/views/page/widgets/CatalogGuildSelectorWidgetView.tsx b/src/components/catalog/views/page/widgets/CatalogGuildSelectorWidgetView.tsx index 77f5d9f6..78a367e9 100644 --- a/src/components/catalog/views/page/widgets/CatalogGuildSelectorWidgetView.tsx +++ b/src/components/catalog/views/page/widgets/CatalogGuildSelectorWidgetView.tsx @@ -1,10 +1,7 @@ import { CatalogGroupsComposer, StringDataType } from '@nitrots/nitro-renderer'; import { FC, useEffect, useMemo, useState } from 'react'; -import { LocalizeText } from '../../../../../api'; -import { Base } from '../../../../../common/Base'; -import { Button } from '../../../../../common/Button'; -import { Flex } from '../../../../../common/Flex'; -import { SendMessageHook } from '../../../../../hooks'; +import { LocalizeText, SendMessageComposer } from '../../../../../api'; +import { Base, Button, Flex } from '../../../../../common'; import { useCatalogContext } from '../../../CatalogContext'; export const CatalogGuildSelectorWidgetView: FC<{}> = props => @@ -43,7 +40,7 @@ export const CatalogGuildSelectorWidgetView: FC<{}> = props => useEffect(() => { - SendMessageHook(new CatalogGroupsComposer()); + SendMessageComposer(new CatalogGroupsComposer()); }, []); if(!groups || !groups.length) diff --git a/src/components/catalog/views/page/widgets/CatalogItemGridWidgetView.tsx b/src/components/catalog/views/page/widgets/CatalogItemGridWidgetView.tsx index dbb20b17..32b5f0b0 100644 --- a/src/components/catalog/views/page/widgets/CatalogItemGridWidgetView.tsx +++ b/src/components/catalog/views/page/widgets/CatalogItemGridWidgetView.tsx @@ -1,7 +1,7 @@ import { FC } from 'react'; import { AutoGrid, AutoGridProps } from '../../../../../common/AutoGrid'; import { CatalogSetExtraPurchaseParameterEvent } from '../../../../../events'; -import { dispatchUiEvent } from '../../../../../hooks'; +import { DispatchUiEvent } from '../../../../../hooks'; import { useCatalogContext } from '../../../CatalogContext'; import { IPurchasableOffer } from '../../../common/IPurchasableOffer'; import { ProductTypeEnum } from '../../../common/ProductTypeEnum'; @@ -29,7 +29,7 @@ export const CatalogItemGridWidgetView: FC = pro if(offer.product && (offer.product.productType === ProductTypeEnum.WALL)) { - dispatchUiEvent(new CatalogSetExtraPurchaseParameterEvent(offer.product.extraParam)); + DispatchUiEvent(new CatalogSetExtraPurchaseParameterEvent(offer.product.extraParam)); } } diff --git a/src/components/catalog/views/page/widgets/CatalogPurchaseWidgetView.tsx b/src/components/catalog/views/page/widgets/CatalogPurchaseWidgetView.tsx index b3cd32bc..bdbcbb79 100644 --- a/src/components/catalog/views/page/widgets/CatalogPurchaseWidgetView.tsx +++ b/src/components/catalog/views/page/widgets/CatalogPurchaseWidgetView.tsx @@ -1,9 +1,9 @@ import { PurchaseFromCatalogComposer } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useMemo, useState } from 'react'; -import { CreateLinkEvent, GetClubMemberLevel, LocalizeText } from '../../../../../api'; +import { CreateLinkEvent, GetClubMemberLevel, LocalizeText, SendMessageComposer } from '../../../../../api'; import { Button, LayoutLoadingSpinnerView } from '../../../../../common'; import { CatalogEvent, CatalogInitGiftEvent, CatalogInitPurchaseEvent, CatalogPurchasedEvent, CatalogPurchaseFailureEvent, CatalogPurchaseNotAllowedEvent, CatalogPurchaseSoldOutEvent, CatalogWidgetEvent } from '../../../../../events'; -import { dispatchUiEvent, SendMessageHook, useUiEvent } from '../../../../../hooks'; +import { DispatchUiEvent, UseUiEvent } from '../../../../../hooks'; import { GetCurrencyAmount } from '../../../../purse/common/CurrencyHelper'; import { useCatalogContext } from '../../../CatalogContext'; import { CatalogPurchaseState } from '../../../common/CatalogPurchaseState'; @@ -31,7 +31,7 @@ export const CatalogPurchaseWidgetView: FC = pro // offer, page.pageId, extraData, quantity, previewStuffData, null, true, null }, [ currentOffer ]); - useUiEvent(CatalogWidgetEvent.INIT_PURCHASE, onCatalogInitPurchaseEvent); + UseUiEvent(CatalogWidgetEvent.INIT_PURCHASE, onCatalogInitPurchaseEvent); const onCatalogEvent = useCallback((event: CatalogEvent) => { @@ -52,10 +52,10 @@ export const CatalogPurchaseWidgetView: FC = pro } }, []); - useUiEvent(CatalogPurchasedEvent.PURCHASE_SUCCESS, onCatalogEvent); - useUiEvent(CatalogPurchaseFailureEvent.PURCHASE_FAILED, onCatalogEvent); - useUiEvent(CatalogPurchaseNotAllowedEvent.NOT_ALLOWED, onCatalogEvent); - useUiEvent(CatalogPurchaseSoldOutEvent.SOLD_OUT, onCatalogEvent); + UseUiEvent(CatalogPurchasedEvent.PURCHASE_SUCCESS, onCatalogEvent); + UseUiEvent(CatalogPurchaseFailureEvent.PURCHASE_FAILED, onCatalogEvent); + UseUiEvent(CatalogPurchaseNotAllowedEvent.NOT_ALLOWED, onCatalogEvent); + UseUiEvent(CatalogPurchaseSoldOutEvent.SOLD_OUT, onCatalogEvent); const isLimitedSoldOut = useMemo(() => { @@ -86,7 +86,7 @@ export const CatalogPurchaseWidgetView: FC = pro if(isGift) { - dispatchUiEvent(new CatalogInitGiftEvent(currentOffer.page.pageId, currentOffer.offerId, extraData)); + DispatchUiEvent(new CatalogInitGiftEvent(currentOffer.page.pageId, currentOffer.offerId, extraData)); return; } @@ -109,7 +109,7 @@ export const CatalogPurchaseWidgetView: FC = pro // if(nodes) pageId = nodes[0].pageId; // } - SendMessageHook(new PurchaseFromCatalogComposer(pageId, currentOffer.offerId, extraData, quantity)); + SendMessageComposer(new PurchaseFromCatalogComposer(pageId, currentOffer.offerId, extraData, quantity)); }, [ currentOffer, purchaseCallback, extraData, quantity ]); useEffect(() => diff --git a/src/components/chat-history/ChatHistoryMessageHandler.tsx b/src/components/chat-history/ChatHistoryMessageHandler.tsx index 89d38a12..87f8e28d 100644 --- a/src/components/chat-history/ChatHistoryMessageHandler.tsx +++ b/src/components/chat-history/ChatHistoryMessageHandler.tsx @@ -1,7 +1,7 @@ import { GetGuestRoomResultEvent, RoomSessionChatEvent, RoomSessionEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useState } from 'react'; import { GetRoomSession } from '../../api'; -import { CreateMessageHook, useRoomSessionManagerEvent } from '../../hooks'; +import { UseMessageEventHook, UseRoomSessionManagerEvent } from '../../hooks'; import { useChatHistoryContext } from './ChatHistoryContext'; import { ChatEntryType } from './common/ChatEntryType'; import { IChatEntry } from './common/IChatEntry'; @@ -64,7 +64,7 @@ export const ChatHistoryMessageHandler: FC<{}> = props => addChatEntry(entry); }, [addChatEntry]); - useRoomSessionManagerEvent(RoomSessionChatEvent.CHAT_EVENT, onChatEvent); + UseRoomSessionManagerEvent(RoomSessionChatEvent.CHAT_EVENT, onChatEvent); const onRoomSessionEvent = useCallback((event: RoomSessionEvent) => { @@ -79,8 +79,8 @@ export const ChatHistoryMessageHandler: FC<{}> = props => } }, []); - useRoomSessionManagerEvent(RoomSessionEvent.ENDED, onRoomSessionEvent); - useRoomSessionManagerEvent(RoomSessionEvent.STARTED, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionEvent.ENDED, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionEvent.STARTED, onRoomSessionEvent); const onGetGuestRoomResultEvent = useCallback((event: GetGuestRoomResultEvent) => { @@ -106,7 +106,7 @@ export const ChatHistoryMessageHandler: FC<{}> = props => } }, [addChatEntry, addRoomHistoryEntry, needsRoomInsert]); - CreateMessageHook(GetGuestRoomResultEvent, onGetGuestRoomResultEvent); + UseMessageEventHook(GetGuestRoomResultEvent, onGetGuestRoomResultEvent); return null; } diff --git a/src/components/groups/GroupsView.tsx b/src/components/groups/GroupsView.tsx index eb0e2091..224fbc20 100644 --- a/src/components/groups/GroupsView.tsx +++ b/src/components/groups/GroupsView.tsx @@ -1,7 +1,7 @@ import { GroupBadgePartsComposer, GroupBadgePartsEvent, GroupPurchasedEvent, GroupSettingsComposer, ILinkEventTracker } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; -import { AddEventLinkTracker, RemoveLinkEventTracker, TryVisitRoom } from '../../api'; -import { CreateMessageHook, SendMessageHook } from '../../hooks'; +import { AddEventLinkTracker, RemoveLinkEventTracker, SendMessageComposer, TryVisitRoom } from '../../api'; +import { UseMessageEventHook } from '../../hooks'; import { CompareId } from './common/CompareId'; import { IGroupCustomize } from './common/IGroupCustomize'; import { GroupsContextProvider } from './GroupsContext'; @@ -23,7 +23,7 @@ export const GroupsView: FC<{}> = props => TryVisitRoom(parser.roomId); }, []); - CreateMessageHook(GroupPurchasedEvent, onGroupPurchasedEvent); + UseMessageEventHook(GroupPurchasedEvent, onGroupPurchasedEvent); const onGroupBadgePartsEvent = useCallback((event: GroupBadgePartsEvent) => { @@ -52,7 +52,7 @@ export const GroupsView: FC<{}> = props => setGroupCustomize(customize); }, [ setGroupCustomize ]); - CreateMessageHook(GroupBadgePartsEvent, onGroupBadgePartsEvent); + UseMessageEventHook(GroupBadgePartsEvent, onGroupBadgePartsEvent); const linkReceived = useCallback((url: string) => { @@ -69,7 +69,7 @@ export const GroupsView: FC<{}> = props => if(!parts[2]) return; setCreatorVisible(false); - SendMessageHook(new GroupSettingsComposer(Number(parts[2]))); + SendMessageComposer(new GroupSettingsComposer(Number(parts[2]))); return; } }, []); @@ -88,7 +88,7 @@ export const GroupsView: FC<{}> = props => useEffect(() => { - SendMessageHook(new GroupBadgePartsComposer()); + SendMessageComposer(new GroupBadgePartsComposer()); }, []); return ( diff --git a/src/components/groups/views/GroupCreatorView.tsx b/src/components/groups/views/GroupCreatorView.tsx index dc8ba132..60feac2b 100644 --- a/src/components/groups/views/GroupCreatorView.tsx +++ b/src/components/groups/views/GroupCreatorView.tsx @@ -1,8 +1,8 @@ import { GroupBuyComposer, GroupBuyDataComposer, GroupBuyDataEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; -import { HasHabboClub, LocalizeText } from '../../../api'; +import { HasHabboClub, LocalizeText, SendMessageComposer } from '../../../api'; import { Base, Button, Column, Flex, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../common'; -import { BatchUpdates, CreateMessageHook, SendMessageHook } from '../../../hooks'; +import { BatchUpdates, UseMessageEventHook } from '../../../hooks'; import { IGroupData } from '../common/IGroupData'; import { GroupTabBadgeView } from './tabs/GroupTabBadgeView'; import { GroupTabColorsView } from './tabs/GroupTabColorsView'; @@ -49,7 +49,7 @@ export const GroupCreatorView: FC = props => } }); - SendMessageHook(new GroupBuyComposer(groupData.groupName, groupData.groupDescription, groupData.groupHomeroomId, groupData.groupColors[0], groupData.groupColors[1], badge)); + SendMessageComposer(new GroupBuyComposer(groupData.groupName, groupData.groupDescription, groupData.groupHomeroomId, groupData.groupColors[0], groupData.groupColors[1], badge)); } const previousStep = () => @@ -101,7 +101,7 @@ export const GroupCreatorView: FC = props => }); }, []); - CreateMessageHook(GroupBuyDataEvent, onGroupBuyDataEvent); + UseMessageEventHook(GroupBuyDataEvent, onGroupBuyDataEvent); useEffect(() => { @@ -121,7 +121,7 @@ export const GroupCreatorView: FC = props => }); }); - SendMessageHook(new GroupBuyDataComposer()); + SendMessageComposer(new GroupBuyDataComposer()); }, [ setGroupData ]); if(!groupData) return null; diff --git a/src/components/groups/views/GroupInformationStandaloneView.tsx b/src/components/groups/views/GroupInformationStandaloneView.tsx index 8298fcf4..27a779dd 100644 --- a/src/components/groups/views/GroupInformationStandaloneView.tsx +++ b/src/components/groups/views/GroupInformationStandaloneView.tsx @@ -2,7 +2,7 @@ import { GroupInformationEvent, GroupInformationParser } from '@nitrots/nitro-re import { FC, useCallback, useState } from 'react'; import { LocalizeText } from '../../../api'; import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../common'; -import { CreateMessageHook } from '../../../hooks'; +import { UseMessageEventHook } from '../../../hooks'; import { GroupInformationView } from './GroupInformationView'; export const GroupInformationStandaloneView: FC<{}> = props => @@ -16,7 +16,7 @@ export const GroupInformationStandaloneView: FC<{}> = props => if((groupInformation && (groupInformation.id === parser.id)) || parser.flag) setGroupInformation(parser); }, [ groupInformation ]); - CreateMessageHook(GroupInformationEvent, onGroupInformationEvent); + UseMessageEventHook(GroupInformationEvent, onGroupInformationEvent); if(!groupInformation) return null; diff --git a/src/components/groups/views/GroupInformationView.tsx b/src/components/groups/views/GroupInformationView.tsx index aef5b7af..121bce5d 100644 --- a/src/components/groups/views/GroupInformationView.tsx +++ b/src/components/groups/views/GroupInformationView.tsx @@ -1,11 +1,7 @@ import { GroupInformationParser, GroupRemoveMemberComposer } from '@nitrots/nitro-renderer'; import { FC, useCallback } from 'react'; -import { CreateLinkEvent, GetSessionDataManager, LocalizeText, TryVisitRoom } from '../../../api'; -import { GetGroupManager } from '../../../api/groups/GetGroupManager'; -import { GetGroupMembers } from '../../../api/groups/GetGroupMembers'; -import { TryJoinGroup } from '../../../api/groups/TryJoinGroup'; +import { CreateLinkEvent, GetGroupManager, GetGroupMembers, GetSessionDataManager, LocalizeText, SendMessageComposer, TryJoinGroup, TryVisitRoom } from '../../../api'; import { Button, Column, Flex, Grid, Text } from '../../../common'; -import { SendMessageHook } from '../../../hooks'; import { NotificationUtilities } from '../../../views/notification-center/common/NotificationUtilities'; import { BadgeImageView } from '../../../views/shared/badge-image/BadgeImageView'; import { CatalogPageName } from '../../catalog/common/CatalogPageName'; @@ -33,7 +29,7 @@ export const GroupInformationView: FC = props => { NotificationUtilities.confirm(LocalizeText('group.leaveconfirm.desc'), () => { - SendMessageHook(new GroupRemoveMemberComposer(groupInformation.id, GetSessionDataManager().userId)); + SendMessageComposer(new GroupRemoveMemberComposer(groupInformation.id, GetSessionDataManager().userId)); if(onClose) onClose(); }, null); diff --git a/src/components/groups/views/GroupManagerView.tsx b/src/components/groups/views/GroupManagerView.tsx index 9c2f659d..4d23e8af 100644 --- a/src/components/groups/views/GroupManagerView.tsx +++ b/src/components/groups/views/GroupManagerView.tsx @@ -2,7 +2,7 @@ import { GroupBadgePart, GroupInformationEvent, GroupSettingsEvent } from '@nitr import { FC, useCallback, useState } from 'react'; import { LocalizeText } from '../../../api'; import { Base, Column, Flex, NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView, Text } from '../../../common'; -import { CreateMessageHook } from '../../../hooks'; +import { UseMessageEventHook } from '../../../hooks'; import { IGroupData } from '../common/IGroupData'; import { GroupTabBadgeView } from './tabs/GroupTabBadgeView'; import { GroupTabColorsView } from './tabs/GroupTabColorsView'; @@ -55,7 +55,7 @@ export const GroupManagerView: FC<{}> = props => }); }, [ groupData ]); - CreateMessageHook(GroupInformationEvent, onGroupInformationEvent); + UseMessageEventHook(GroupInformationEvent, onGroupInformationEvent); const onGroupSettingsEvent = useCallback((event: GroupSettingsEvent) => { @@ -85,7 +85,7 @@ export const GroupManagerView: FC<{}> = props => }); }, [ setGroupData ]); - CreateMessageHook(GroupSettingsEvent, onGroupSettingsEvent); + UseMessageEventHook(GroupSettingsEvent, onGroupSettingsEvent); if(!groupData || (groupData.groupId <= 0)) return null; diff --git a/src/components/groups/views/GroupMembersView.tsx b/src/components/groups/views/GroupMembersView.tsx index 07894431..446b270e 100644 --- a/src/components/groups/views/GroupMembersView.tsx +++ b/src/components/groups/views/GroupMembersView.tsx @@ -1,9 +1,9 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { GroupAdminGiveComposer, GroupAdminTakeComposer, GroupConfirmMemberRemoveEvent, GroupConfirmRemoveMemberComposer, GroupMemberParser, GroupMembersComposer, GroupMembersEvent, GroupMembershipAcceptComposer, GroupMembershipDeclineComposer, GroupMembersParser, GroupRank, GroupRemoveMemberComposer, ILinkEventTracker } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; -import { AddEventLinkTracker, GetSessionDataManager, GetUserProfile, LocalizeText, RemoveLinkEventTracker } from '../../../api'; +import { AddEventLinkTracker, GetSessionDataManager, GetUserProfile, LocalizeText, RemoveLinkEventTracker, SendMessageComposer } from '../../../api'; import { Base, Button, Column, Flex, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../common'; -import { BatchUpdates, CreateMessageHook, SendMessageHook } from '../../../hooks'; +import { BatchUpdates, UseMessageEventHook } from '../../../hooks'; import { NotificationUtilities } from '../../../views/notification-center/common/NotificationUtilities'; import { AvatarImageView } from '../../../views/shared/avatar-image/AvatarImageView'; import { BadgeImageView } from '../../../views/shared/badge-image/BadgeImageView'; @@ -36,15 +36,15 @@ export const GroupMembersView: FC<{}> = props => { if((groupId === -1) || (levelId === -1) || (pageId === -1)) return; - SendMessageHook(new GroupMembersComposer(groupId, pageId, searchQuery, levelId)); + SendMessageComposer(new GroupMembersComposer(groupId, pageId, searchQuery, levelId)); }, [ groupId, levelId, pageId, searchQuery ]); const toggleAdmin = (member: GroupMemberParser) => { if(!membersData.admin || (member.rank === GroupRank.OWNER)) return; - if(member.rank !== GroupRank.ADMIN) SendMessageHook(new GroupAdminGiveComposer(membersData.groupId, member.id)); - else SendMessageHook(new GroupAdminTakeComposer(membersData.groupId, member.id)); + if(member.rank !== GroupRank.ADMIN) SendMessageComposer(new GroupAdminGiveComposer(membersData.groupId, member.id)); + else SendMessageComposer(new GroupAdminTakeComposer(membersData.groupId, member.id)); refreshMembers(); } @@ -53,7 +53,7 @@ export const GroupMembersView: FC<{}> = props => { if(!membersData.admin || (member.rank !== GroupRank.REQUESTED)) return; - SendMessageHook(new GroupMembershipAcceptComposer(membersData.groupId, member.id)); + SendMessageComposer(new GroupMembershipAcceptComposer(membersData.groupId, member.id)); refreshMembers(); } @@ -64,7 +64,7 @@ export const GroupMembersView: FC<{}> = props => if(member.rank === GroupRank.REQUESTED) { - SendMessageHook(new GroupMembershipDeclineComposer(membersData.groupId, member.id)); + SendMessageComposer(new GroupMembershipDeclineComposer(membersData.groupId, member.id)); refreshMembers(); @@ -72,7 +72,7 @@ export const GroupMembersView: FC<{}> = props => } setRemovingMemberName(member.name); - SendMessageHook(new GroupConfirmRemoveMemberComposer(membersData.groupId, member.id)); + SendMessageComposer(new GroupConfirmRemoveMemberComposer(membersData.groupId, member.id)); } const onGroupMembersEvent = useCallback((event: GroupMembersEvent) => @@ -87,7 +87,7 @@ export const GroupMembersView: FC<{}> = props => }); }, []); - CreateMessageHook(GroupMembersEvent, onGroupMembersEvent); + UseMessageEventHook(GroupMembersEvent, onGroupMembersEvent); const onGroupConfirmMemberRemoveEvent = useCallback((event: GroupConfirmMemberRemoveEvent) => { @@ -95,7 +95,7 @@ export const GroupMembersView: FC<{}> = props => NotificationUtilities.confirm(LocalizeText(((parser.furnitureCount > 0) ? 'group.kickconfirm.desc' : 'group.kickconfirm_nofurni.desc'), [ 'user', 'amount' ], [ removingMemberName, parser.furnitureCount.toString() ]), () => { - SendMessageHook(new GroupRemoveMemberComposer(membersData.groupId, parser.userId)); + SendMessageComposer(new GroupRemoveMemberComposer(membersData.groupId, parser.userId)); refreshMembers(); }, null); @@ -103,7 +103,7 @@ export const GroupMembersView: FC<{}> = props => setRemovingMemberName(null); }, [ membersData, removingMemberName, refreshMembers ]); - CreateMessageHook(GroupConfirmMemberRemoveEvent, onGroupConfirmMemberRemoveEvent); + UseMessageEventHook(GroupConfirmMemberRemoveEvent, onGroupConfirmMemberRemoveEvent); const linkReceived = useCallback((url: string) => { @@ -142,7 +142,7 @@ export const GroupMembersView: FC<{}> = props => { if((groupId === -1) || (levelId === -1) || (pageId === -1)) return; - SendMessageHook(new GroupMembersComposer(groupId, pageId, searchQuery, levelId)); + SendMessageComposer(new GroupMembersComposer(groupId, pageId, searchQuery, levelId)); }, [ groupId, levelId, pageId, searchQuery ]); useEffect(() => diff --git a/src/components/groups/views/GroupRoomInformationView.tsx b/src/components/groups/views/GroupRoomInformationView.tsx index d1088685..8900d9ea 100644 --- a/src/components/groups/views/GroupRoomInformationView.tsx +++ b/src/components/groups/views/GroupRoomInformationView.tsx @@ -1,10 +1,9 @@ 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 { GetGroupInformation, GetSessionDataManager, LocalizeText, TryJoinGroup } from '../../../api'; -import { GetGroupManager } from '../../../api/groups/GetGroupManager'; +import { GetGroupInformation, GetGroupManager, GetSessionDataManager, LocalizeText, SendMessageComposer, TryJoinGroup } from '../../../api'; import { Base, Button, Column, Flex, Text } from '../../../common'; -import { CreateMessageHook, SendMessageHook } from '../../../hooks'; +import { UseMessageEventHook } from '../../../hooks'; import { NotificationUtilities } from '../../../views/notification-center/common/NotificationUtilities'; import { BadgeImageView } from '../../../views/shared/badge-image/BadgeImageView'; import { GroupMembershipType } from '../common/GroupMembershipType'; @@ -22,7 +21,7 @@ export const GroupRoomInformationView: FC<{}> = props => setGroupInformation(null); }, []); - CreateMessageHook(DesktopViewEvent, onDesktopViewEvent); + UseMessageEventHook(DesktopViewEvent, onDesktopViewEvent); const onRoomEntryInfoMessageEvent = useCallback((event: RoomEntryInfoMessageEvent) => { @@ -30,7 +29,7 @@ export const GroupRoomInformationView: FC<{}> = props => setGroupInformation(null); }, []); - CreateMessageHook(RoomEntryInfoMessageEvent, onRoomEntryInfoMessageEvent); + UseMessageEventHook(RoomEntryInfoMessageEvent, onRoomEntryInfoMessageEvent); const onGetGuestRoomResultEvent = useCallback((event: GetGuestRoomResultEvent) => { @@ -41,7 +40,7 @@ export const GroupRoomInformationView: FC<{}> = props => if(parser.data.habboGroupId > 0) { setExpectedGroupId(parser.data.habboGroupId); - SendMessageHook(new GroupInformationComposer(parser.data.habboGroupId, false)); + SendMessageComposer(new GroupInformationComposer(parser.data.habboGroupId, false)); } else { @@ -50,7 +49,7 @@ export const GroupRoomInformationView: FC<{}> = props => } }, []); - CreateMessageHook(GetGuestRoomResultEvent, onGetGuestRoomResultEvent); + UseMessageEventHook(GetGuestRoomResultEvent, onGetGuestRoomResultEvent); const onHabboGroupDeactivatedMessageEvent = useCallback((event: HabboGroupDeactivatedMessageEvent) => { @@ -62,7 +61,7 @@ export const GroupRoomInformationView: FC<{}> = props => setGroupInformation(null); }, [ expectedGroupId, groupInformation ]); - CreateMessageHook(HabboGroupDeactivatedMessageEvent, onHabboGroupDeactivatedMessageEvent); + UseMessageEventHook(HabboGroupDeactivatedMessageEvent, onHabboGroupDeactivatedMessageEvent); const onGroupInformationEvent = useCallback((event: GroupInformationEvent) => { @@ -73,13 +72,13 @@ export const GroupRoomInformationView: FC<{}> = props => setGroupInformation(parser); }, [ expectedGroupId ]); - CreateMessageHook(GroupInformationEvent, onGroupInformationEvent); + UseMessageEventHook(GroupInformationEvent, onGroupInformationEvent); const leaveGroup = () => { NotificationUtilities.confirm(LocalizeText('group.leaveconfirm.desc'), () => { - SendMessageHook(new GroupRemoveMemberComposer(groupInformation.id, GetSessionDataManager().userId)); + SendMessageComposer(new GroupRemoveMemberComposer(groupInformation.id, GetSessionDataManager().userId)); }, null); } diff --git a/src/components/groups/views/tabs/GroupTabBadgeView.tsx b/src/components/groups/views/tabs/GroupTabBadgeView.tsx index 9b70f702..e6e5dfc6 100644 --- a/src/components/groups/views/tabs/GroupTabBadgeView.tsx +++ b/src/components/groups/views/tabs/GroupTabBadgeView.tsx @@ -1,7 +1,7 @@ import { GroupSaveBadgeComposer } from '@nitrots/nitro-renderer'; import { Dispatch, FC, SetStateAction, useCallback, useEffect, useState } from 'react'; +import { SendMessageComposer } from '../../../../api'; import { Column, Flex, Grid } from '../../../../common'; -import { SendMessageHook } from '../../../../hooks'; import { BadgeImageView } from '../../../../views/shared/badge-image/BadgeImageView'; import { GroupBadgePart } from '../../common/GroupBadgePart'; import { IGroupData } from '../../common/IGroupData'; @@ -64,7 +64,7 @@ export const GroupTabBadgeView: FC = props => badge.push(part.position); }); - SendMessageHook(new GroupSaveBadgeComposer(groupData.groupId, badge)); + SendMessageComposer(new GroupSaveBadgeComposer(groupData.groupId, badge)); return true; }, [ groupData, badgeParts, setGroupData ]); diff --git a/src/components/groups/views/tabs/GroupTabColorsView.tsx b/src/components/groups/views/tabs/GroupTabColorsView.tsx index 2dcf4220..416f975a 100644 --- a/src/components/groups/views/tabs/GroupTabColorsView.tsx +++ b/src/components/groups/views/tabs/GroupTabColorsView.tsx @@ -1,9 +1,8 @@ import { GroupSaveColorsComposer } from '@nitrots/nitro-renderer'; import classNames from 'classnames'; import { Dispatch, FC, SetStateAction, useCallback, useEffect, useState } from 'react'; -import { LocalizeText } from '../../../../api'; +import { LocalizeText, SendMessageComposer } from '../../../../api'; import { AutoGrid, Base, Column, Flex, Grid, Text } from '../../../../common'; -import { SendMessageHook } from '../../../../hooks'; import { IGroupData } from '../../common/IGroupData'; import { useGroupsContext } from '../../GroupsContext'; @@ -59,7 +58,7 @@ export const GroupTabColorsView: FC = props => return true; } - SendMessageHook(new GroupSaveColorsComposer(groupData.groupId, colors[0], colors[1])); + SendMessageComposer(new GroupSaveColorsComposer(groupData.groupId, colors[0], colors[1])); return true; }, [ groupData, colors, setGroupData ]); diff --git a/src/components/groups/views/tabs/GroupTabIdentityView.tsx b/src/components/groups/views/tabs/GroupTabIdentityView.tsx index 974f66a9..a4c39719 100644 --- a/src/components/groups/views/tabs/GroupTabIdentityView.tsx +++ b/src/components/groups/views/tabs/GroupTabIdentityView.tsx @@ -1,8 +1,8 @@ import { GroupDeleteComposer, GroupSaveInformationComposer } from '@nitrots/nitro-renderer'; import { Dispatch, FC, SetStateAction, useCallback, useEffect, useState } from 'react'; -import { CreateLinkEvent, LocalizeText } from '../../../../api'; +import { CreateLinkEvent, LocalizeText, SendMessageComposer } from '../../../../api'; import { Base, Button, Column, Flex, Text } from '../../../../common'; -import { BatchUpdates, SendMessageHook } from '../../../../hooks'; +import { BatchUpdates } from '../../../../hooks'; import { NotificationUtilities } from '../../../../views/notification-center/common/NotificationUtilities'; import { IGroupData } from '../../common/IGroupData'; @@ -28,7 +28,7 @@ export const GroupTabIdentityView: FC = props => NotificationUtilities.confirm(LocalizeText('group.deleteconfirm.desc'), () => { - SendMessageHook(new GroupDeleteComposer(groupData.groupId)); + SendMessageComposer(new GroupDeleteComposer(groupData.groupId)); }, null, null, null, LocalizeText('group.deleteconfirm.title')); } @@ -56,7 +56,7 @@ export const GroupTabIdentityView: FC = props => return true; } - SendMessageHook(new GroupSaveInformationComposer(groupData.groupId, groupName, (groupDescription || ''))); + SendMessageComposer(new GroupSaveInformationComposer(groupData.groupId, groupName, (groupDescription || ''))); return true; }, [ groupData, groupName, groupDescription, groupHomeroomId, setGroupData ]); diff --git a/src/components/groups/views/tabs/GroupTabSettingsView.tsx b/src/components/groups/views/tabs/GroupTabSettingsView.tsx index 5c8e186e..f9ba86fe 100644 --- a/src/components/groups/views/tabs/GroupTabSettingsView.tsx +++ b/src/components/groups/views/tabs/GroupTabSettingsView.tsx @@ -1,8 +1,9 @@ import { GroupSavePreferencesComposer } from '@nitrots/nitro-renderer'; import { Dispatch, FC, SetStateAction, useCallback, useEffect, useState } from 'react'; +import { SendMessageComposer } from '../../../../api'; import { LocalizeText } from '../../../../api/utils/LocalizeText'; import { Column, Flex, HorizontalRule, Text } from '../../../../common'; -import { BatchUpdates, SendMessageHook } from '../../../../hooks'; +import { BatchUpdates } from '../../../../hooks'; import { IGroupData } from '../../common/IGroupData'; const STATES: string[] = [ 'regular', 'exclusive', 'private' ]; @@ -41,7 +42,7 @@ export const GroupTabSettingsView: FC = props => return true; } - SendMessageHook(new GroupSavePreferencesComposer(groupData.groupId, groupState, groupDecorate ? 0 : 1)); + SendMessageComposer(new GroupSavePreferencesComposer(groupData.groupId, groupState, groupDecorate ? 0 : 1)); return true; }, [ groupData, groupState, groupDecorate, setGroupData ]); diff --git a/src/components/guide-tool/GuideToolView.tsx b/src/components/guide-tool/GuideToolView.tsx index bedcb531..7a4860fa 100644 --- a/src/components/guide-tool/GuideToolView.tsx +++ b/src/components/guide-tool/GuideToolView.tsx @@ -1,9 +1,9 @@ import { GuideOnDutyStatusMessageEvent, GuideSessionAttachedMessageEvent, GuideSessionDetachedMessageEvent, GuideSessionEndedMessageEvent, GuideSessionInvitedToGuideRoomMessageEvent, GuideSessionMessageMessageEvent, GuideSessionOnDutyUpdateMessageComposer, GuideSessionPartnerIsTypingMessageEvent, GuideSessionStartedMessageEvent, ILinkEventTracker, PerkAllowancesMessageEvent, PerkEnum } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; -import { AddEventLinkTracker, GetConfiguration, GetSessionDataManager, LocalizeText, RemoveLinkEventTracker } from '../../api'; +import { AddEventLinkTracker, GetConfiguration, GetSessionDataManager, LocalizeText, RemoveLinkEventTracker, SendMessageComposer } from '../../api'; import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../common'; import { GuideToolEvent, NotificationAlertEvent } from '../../events'; -import { CreateMessageHook, dispatchUiEvent, SendMessageHook, useUiEvent } from '../../hooks'; +import { DispatchUiEvent, UseMessageEventHook, UseUiEvent } from '../../hooks'; import { GuideSessionState } from './common/GuideSessionState'; import { GuideToolMessage } from './common/GuideToolMessage'; import { GuideToolMessageGroup } from './common/GuideToolMessageGroup'; @@ -103,10 +103,10 @@ export const GuideToolView: FC<{}> = props => } }, [ updateSessionState ]); - useUiEvent(GuideToolEvent.SHOW_GUIDE_TOOL, onGuideToolEvent); - useUiEvent(GuideToolEvent.HIDE_GUIDE_TOOL, onGuideToolEvent); - useUiEvent(GuideToolEvent.TOGGLE_GUIDE_TOOL, onGuideToolEvent); - useUiEvent(GuideToolEvent.CREATE_HELP_REQUEST, onGuideToolEvent); + UseUiEvent(GuideToolEvent.SHOW_GUIDE_TOOL, onGuideToolEvent); + UseUiEvent(GuideToolEvent.HIDE_GUIDE_TOOL, onGuideToolEvent); + UseUiEvent(GuideToolEvent.TOGGLE_GUIDE_TOOL, onGuideToolEvent); + UseUiEvent(GuideToolEvent.CREATE_HELP_REQUEST, onGuideToolEvent); const onPerkAllowancesMessageEvent = useCallback((event: PerkAllowancesMessageEvent) => { @@ -115,11 +115,11 @@ export const GuideToolView: FC<{}> = props => if(!parser.isAllowed(PerkEnum.USE_GUIDE_TOOL) && isOnDuty) { setIsOnDuty(false); - SendMessageHook(new GuideSessionOnDutyUpdateMessageComposer(false, false, false, false)); + SendMessageComposer(new GuideSessionOnDutyUpdateMessageComposer(false, false, false, false)); } }, [ isOnDuty, setIsOnDuty ]); - CreateMessageHook(PerkAllowancesMessageEvent, onPerkAllowancesMessageEvent); + UseMessageEventHook(PerkAllowancesMessageEvent, onPerkAllowancesMessageEvent); const onGuideOnDutyStatusMessageEvent = useCallback((event: GuideOnDutyStatusMessageEvent) => { @@ -131,7 +131,7 @@ export const GuideToolView: FC<{}> = props => setGuardiansOnDuty(parser.guardiansOnDuty); }, [ setIsOnDuty, setHelpersOnDuty, setGuidesOnDuty, setGuardiansOnDuty ]); - CreateMessageHook(GuideOnDutyStatusMessageEvent, onGuideOnDutyStatusMessageEvent); + UseMessageEventHook(GuideOnDutyStatusMessageEvent, onGuideOnDutyStatusMessageEvent); const onGuideSessionAttachedMessageEvent = useCallback((event: GuideSessionAttachedMessageEvent) => { @@ -146,7 +146,7 @@ export const GuideToolView: FC<{}> = props => }, [ isOnDuty, updateSessionState ]); - CreateMessageHook(GuideSessionAttachedMessageEvent, onGuideSessionAttachedMessageEvent); + UseMessageEventHook(GuideSessionAttachedMessageEvent, onGuideSessionAttachedMessageEvent); const onGuideSessionStartedMessageEvent = useCallback((event: GuideSessionStartedMessageEvent) => { @@ -168,7 +168,7 @@ export const GuideToolView: FC<{}> = props => } }, [ isOnDuty, updateSessionState ]); - CreateMessageHook(GuideSessionStartedMessageEvent, onGuideSessionStartedMessageEvent); + UseMessageEventHook(GuideSessionStartedMessageEvent, onGuideSessionStartedMessageEvent); const onGuideSessionPartnerIsTypingMessageEvent = useCallback((event: GuideSessionPartnerIsTypingMessageEvent) => { @@ -177,7 +177,7 @@ export const GuideToolView: FC<{}> = props => setOngoingIsTyping(parser.isTyping); }, []); - CreateMessageHook(GuideSessionPartnerIsTypingMessageEvent, onGuideSessionPartnerIsTypingMessageEvent); + UseMessageEventHook(GuideSessionPartnerIsTypingMessageEvent, onGuideSessionPartnerIsTypingMessageEvent); const onGuideSessionMessageMessageEvent = useCallback((event: GuideSessionMessageMessageEvent) => { @@ -197,7 +197,7 @@ export const GuideToolView: FC<{}> = props => setOngoingMessageGroups(messageGroups); }, [ ongoingMessageGroups ]); - CreateMessageHook(GuideSessionMessageMessageEvent, onGuideSessionMessageMessageEvent); + UseMessageEventHook(GuideSessionMessageMessageEvent, onGuideSessionMessageMessageEvent); const onGuideSessionInvitedToGuideRoomMessageEvent = useCallback((event: GuideSessionInvitedToGuideRoomMessageEvent) => { @@ -219,7 +219,7 @@ export const GuideToolView: FC<{}> = props => setOngoingMessageGroups(messageGroups); }, [isOnDuty, ongoingMessageGroups, ongoingUserId]); - CreateMessageHook(GuideSessionInvitedToGuideRoomMessageEvent, onGuideSessionInvitedToGuideRoomMessageEvent); + UseMessageEventHook(GuideSessionInvitedToGuideRoomMessageEvent, onGuideSessionInvitedToGuideRoomMessageEvent); const onGuideSessionEndedMessageEvent = useCallback((event: GuideSessionEndedMessageEvent) => { @@ -238,7 +238,7 @@ export const GuideToolView: FC<{}> = props => } }, [ isOnDuty, updateSessionState ]); - CreateMessageHook(GuideSessionEndedMessageEvent, onGuideSessionEndedMessageEvent); + UseMessageEventHook(GuideSessionEndedMessageEvent, onGuideSessionEndedMessageEvent); const onGuideSessionDetachedMessageEvent = useCallback((event: GuideSessionDetachedMessageEvent) => { @@ -259,7 +259,7 @@ export const GuideToolView: FC<{}> = props => } }, [ isOnDuty, updateSessionState ]); - CreateMessageHook(GuideSessionDetachedMessageEvent, onGuideSessionDetachedMessageEvent); + UseMessageEventHook(GuideSessionDetachedMessageEvent, onGuideSessionDetachedMessageEvent); const linkReceived = useCallback((url: string) => { @@ -299,13 +299,13 @@ export const GuideToolView: FC<{}> = props => case 'toggle_duty': if(!isHandlingBullyReports && !isHandlingGuideRequests && !isHandlingHelpRequests) { - dispatchUiEvent(new NotificationAlertEvent([LocalizeText('guide.help.guide.tool.noqueueselected.message')], null, null, null, LocalizeText('guide.help.guide.tool.noqueueselected.caption'), null)); + DispatchUiEvent(new NotificationAlertEvent([LocalizeText('guide.help.guide.tool.noqueueselected.message')], null, null, null, LocalizeText('guide.help.guide.tool.noqueueselected.caption'), null)); return; } setIsOnDuty(v => { - SendMessageHook(new GuideSessionOnDutyUpdateMessageComposer(!v, v ? false : isHandlingGuideRequests, v ? false : isHandlingHelpRequests, v ? false : isHandlingBullyReports)); + SendMessageComposer(new GuideSessionOnDutyUpdateMessageComposer(!v, v ? false : isHandlingGuideRequests, v ? false : isHandlingHelpRequests, v ? false : isHandlingBullyReports)); return !v; }); diff --git a/src/components/guide-tool/views/GuideToolAcceptView.tsx b/src/components/guide-tool/views/GuideToolAcceptView.tsx index 21368ebd..05f6f6fc 100644 --- a/src/components/guide-tool/views/GuideToolAcceptView.tsx +++ b/src/components/guide-tool/views/GuideToolAcceptView.tsx @@ -1,8 +1,7 @@ import { GuideSessionGuideDecidesMessageComposer } from '@nitrots/nitro-renderer'; import { FC } from 'react'; -import { LocalizeText } from '../../../api'; +import { LocalizeText, SendMessageComposer } from '../../../api'; import { Button, Column, Text } from '../../../common'; -import { SendMessageHook } from '../../../hooks'; interface GuideToolAcceptViewProps { @@ -14,7 +13,7 @@ export const GuideToolAcceptView: FC = props => { const { helpRequestDescription = null, helpRequestAverageTime = 0 } = props; - const answerRequest = (response: boolean) => SendMessageHook(new GuideSessionGuideDecidesMessageComposer(response)); + const answerRequest = (response: boolean) => SendMessageComposer(new GuideSessionGuideDecidesMessageComposer(response)); return ( diff --git a/src/components/guide-tool/views/GuideToolOngoingView.tsx b/src/components/guide-tool/views/GuideToolOngoingView.tsx index dc19d7b4..f22f6347 100644 --- a/src/components/guide-tool/views/GuideToolOngoingView.tsx +++ b/src/components/guide-tool/views/GuideToolOngoingView.tsx @@ -1,9 +1,9 @@ import { GuideSessionGetRequesterRoomMessageComposer, GuideSessionInviteRequesterMessageComposer, GuideSessionRequesterRoomMessageEvent, GuideSessionResolvedMessageComposer } from '@nitrots/nitro-renderer'; import { GuideSessionMessageMessageComposer } from '@nitrots/nitro-renderer/src'; import { FC, KeyboardEvent, useCallback, useState } from 'react'; -import { GetSessionDataManager, LocalizeText, TryVisitRoom } from '../../../api'; +import { GetSessionDataManager, LocalizeText, SendMessageComposer, TryVisitRoom } from '../../../api'; import { Base, Button, ButtonGroup, Column, Flex, Text } from '../../../common'; -import { CreateMessageHook, SendMessageHook } from '../../../hooks'; +import { UseMessageEventHook } from '../../../hooks'; import { AvatarImageView } from '../../../views/shared/avatar-image/AvatarImageView'; import { GuideToolMessageGroup } from '../common/GuideToolMessageGroup'; @@ -25,17 +25,17 @@ export const GuideToolOngoingView: FC = props => const visit = useCallback(() => { - SendMessageHook(new GuideSessionGetRequesterRoomMessageComposer()); + SendMessageComposer(new GuideSessionGetRequesterRoomMessageComposer()); }, []); const invite = useCallback(() => { - SendMessageHook(new GuideSessionInviteRequesterMessageComposer()); + SendMessageComposer(new GuideSessionInviteRequesterMessageComposer()); }, []); const resolve = useCallback(() => { - SendMessageHook(new GuideSessionResolvedMessageComposer()); + SendMessageComposer(new GuideSessionResolvedMessageComposer()); }, []); const onGuideSessionRequesterRoomMessageEvent = useCallback((event: GuideSessionRequesterRoomMessageEvent) => @@ -45,13 +45,13 @@ export const GuideToolOngoingView: FC = props => TryVisitRoom(parser.requesterRoomId); }, []); - CreateMessageHook(GuideSessionRequesterRoomMessageEvent, onGuideSessionRequesterRoomMessageEvent); + UseMessageEventHook(GuideSessionRequesterRoomMessageEvent, onGuideSessionRequesterRoomMessageEvent); const sendMessage = useCallback(() => { if(!messageText || !messageText.length) return; - SendMessageHook(new GuideSessionMessageMessageComposer(messageText)); + SendMessageComposer(new GuideSessionMessageMessageComposer(messageText)); setMessageText(''); }, [ messageText ]); diff --git a/src/components/guide-tool/views/GuideToolUserCreateRequestView.tsx b/src/components/guide-tool/views/GuideToolUserCreateRequestView.tsx index c910a8b7..e069c072 100644 --- a/src/components/guide-tool/views/GuideToolUserCreateRequestView.tsx +++ b/src/components/guide-tool/views/GuideToolUserCreateRequestView.tsx @@ -1,8 +1,7 @@ import { GuideSessionCreateMessageComposer } from '@nitrots/nitro-renderer'; import { FC, useState } from 'react'; -import { LocalizeText } from '../../../api'; +import { LocalizeText, SendMessageComposer } from '../../../api'; import { Button, Column, Text } from '../../../common'; -import { SendMessageHook } from '../../../hooks'; interface GuideToolUserCreateRequestViewProps { @@ -20,7 +19,7 @@ export const GuideToolUserCreateRequestView: FC { setIsPending(true); - SendMessageHook(new GuideSessionCreateMessageComposer(1, userRequest)); + SendMessageComposer(new GuideSessionCreateMessageComposer(1, userRequest)); } return ( diff --git a/src/components/guide-tool/views/GuideToolUserFeedbackView.tsx b/src/components/guide-tool/views/GuideToolUserFeedbackView.tsx index 9a8b8f60..bc978353 100644 --- a/src/components/guide-tool/views/GuideToolUserFeedbackView.tsx +++ b/src/components/guide-tool/views/GuideToolUserFeedbackView.tsx @@ -1,8 +1,7 @@ import { GuideSessionFeedbackMessageComposer } from '@nitrots/nitro-renderer'; import { FC, useCallback } from 'react'; -import { LocalizeText } from '../../../api'; +import { LocalizeText, SendMessageComposer } from '../../../api'; import { Button, Column, Flex, Text } from '../../../common'; -import { SendMessageHook } from '../../../hooks'; interface GuideToolUserFeedbackViewProps { @@ -15,7 +14,7 @@ export const GuideToolUserFeedbackView: FC = pro const giveFeedback = useCallback((recommend: boolean) => { - SendMessageHook(new GuideSessionFeedbackMessageComposer(recommend)); + SendMessageComposer(new GuideSessionFeedbackMessageComposer(recommend)); }, []); return ( diff --git a/src/components/guide-tool/views/GuideToolUserPendingView.tsx b/src/components/guide-tool/views/GuideToolUserPendingView.tsx index 49959a4d..81faaff8 100644 --- a/src/components/guide-tool/views/GuideToolUserPendingView.tsx +++ b/src/components/guide-tool/views/GuideToolUserPendingView.tsx @@ -1,8 +1,7 @@ import { GuideSessionRequesterCancelsMessageComposer } from '@nitrots/nitro-renderer'; import { FC } from 'react'; -import { LocalizeText } from '../../../api'; +import { LocalizeText, SendMessageComposer } from '../../../api'; import { Button, Column, Text } from '../../../common'; -import { SendMessageHook } from '../../../hooks'; interface GuideToolUserPendingViewProps { @@ -14,7 +13,7 @@ export const GuideToolUserPendingView: FC = props { const { helpRequestDescription = null, helpRequestAverageTime = 0 } = props; - const cancelRequest = () => SendMessageHook(new GuideSessionRequesterCancelsMessageComposer()); + const cancelRequest = () => SendMessageComposer(new GuideSessionRequesterCancelsMessageComposer()); return ( diff --git a/src/components/help/HelpMessageHandler.tsx b/src/components/help/HelpMessageHandler.tsx index 22b277f1..3f538542 100644 --- a/src/components/help/HelpMessageHandler.tsx +++ b/src/components/help/HelpMessageHandler.tsx @@ -1,7 +1,7 @@ import { CallForHelpResultMessageEvent, GetPendingCallsForHelpMessageComposer, IssueCloseNotificationMessageEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback } from 'react'; -import { LocalizeText } from '../../api'; -import { CreateMessageHook, SendMessageHook } from '../../hooks/messages/message-event'; +import { LocalizeText, SendMessageComposer } from '../../api'; +import { UseMessageEventHook } from '../../hooks'; import { NotificationAlertType } from '../../views/notification-center/common/NotificationAlertType'; import { NotificationUtilities } from '../../views/notification-center/common/NotificationUtilities'; import { CallForHelpResult } from './common/CallForHelpResult'; @@ -18,7 +18,7 @@ export const HelpMessageHandler: FC<{}> = props => switch(parser.resultType) { case CallForHelpResult.TOO_MANY_PENDING_CALLS_CODE: - SendMessageHook(new GetPendingCallsForHelpMessageComposer()); + SendMessageComposer(new GetPendingCallsForHelpMessageComposer()); NotificationUtilities.simpleAlert(LocalizeText('help.cfh.error.pending'), NotificationAlertType.MODERATION, null, null, LocalizeText('help.cfh.error.title')); break; case CallForHelpResult.HAS_ABUSIVE_CALL_CODE: @@ -33,7 +33,7 @@ export const HelpMessageHandler: FC<{}> = props => } }, []); - CreateMessageHook(CallForHelpResultMessageEvent, onCallForHelpResultMessageEvent); + UseMessageEventHook(CallForHelpResultMessageEvent, onCallForHelpResultMessageEvent); const onIssueCloseNotificationMessageEvent = useCallback((event: IssueCloseNotificationMessageEvent) => { @@ -44,7 +44,7 @@ export const HelpMessageHandler: FC<{}> = props => NotificationUtilities.simpleAlert(message, NotificationAlertType.MODERATION, null, null, LocalizeText('mod.alert.title')); }, []); - CreateMessageHook(IssueCloseNotificationMessageEvent, onIssueCloseNotificationMessageEvent); + UseMessageEventHook(IssueCloseNotificationMessageEvent, onIssueCloseNotificationMessageEvent); return null; } diff --git a/src/components/help/HelpView.tsx b/src/components/help/HelpView.tsx index 3fea8b38..18129cf8 100644 --- a/src/components/help/HelpView.tsx +++ b/src/components/help/HelpView.tsx @@ -3,7 +3,7 @@ import { FC, useCallback, useEffect, useState } from 'react'; import { AddEventLinkTracker, LocalizeText, RemoveLinkEventTracker } from '../../api'; import { Base, Column, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../common'; import { HelpReportUserEvent } from '../../events/help/HelpReportUserEvent'; -import { useUiEvent } from '../../hooks'; +import { UseUiEvent } from '../../hooks'; import { IHelpReportState } from './common/IHelpReportState'; import { HelpContextProvider } from './HelpContext'; import { HelpMessageHandler } from './HelpMessageHandler'; @@ -63,7 +63,7 @@ export const HelpView: FC<{}> = props => setIsVisible(true); }, []); - useUiEvent(HelpReportUserEvent.REPORT_USER, onHelpReportUserEvent); + UseUiEvent(HelpReportUserEvent.REPORT_USER, onHelpReportUserEvent); useEffect(() => { diff --git a/src/components/help/views/DescribeReportView.tsx b/src/components/help/views/DescribeReportView.tsx index 02c764d0..634cbe05 100644 --- a/src/components/help/views/DescribeReportView.tsx +++ b/src/components/help/views/DescribeReportView.tsx @@ -1,8 +1,7 @@ import { CallForHelpMessageComposer } from '@nitrots/nitro-renderer'; import { FC, useState } from 'react'; -import { CreateLinkEvent, LocalizeText } from '../../../api'; +import { CreateLinkEvent, LocalizeText, SendMessageComposer } from '../../../api'; import { Button, Column, Text } from '../../../common'; -import { SendMessageHook } from '../../../hooks'; import { useHelpContext } from '../HelpContext'; export const DescribeReportView: FC<{}> = props => @@ -24,7 +23,7 @@ export const DescribeReportView: FC<{}> = props => chats.push(entry.message); }); - SendMessageHook(new CallForHelpMessageComposer(message, cfhTopic, reportedUserId, roomId, chats)); + SendMessageComposer(new CallForHelpMessageComposer(message, cfhTopic, reportedUserId, roomId, chats)); CreateLinkEvent('help/hide'); } diff --git a/src/components/help/views/HelpIndexView.tsx b/src/components/help/views/HelpIndexView.tsx index bec9167e..c083572f 100644 --- a/src/components/help/views/HelpIndexView.tsx +++ b/src/components/help/views/HelpIndexView.tsx @@ -1,11 +1,9 @@ import { GetCfhStatusMessageComposer } from '@nitrots/nitro-renderer'; import { FC, useCallback } from 'react'; -import { LocalizeText } from '../../../api'; -import { Button } from '../../../common/Button'; -import { Column } from '../../../common/Column'; -import { Text } from '../../../common/Text'; -import { GuideToolEvent } from '../../../events/guide-tool/GuideToolEvent'; -import { dispatchUiEvent, SendMessageHook } from '../../../hooks'; +import { LocalizeText, SendMessageComposer } from '../../../api'; +import { Button, Column, Text } from '../../../common'; +import { GuideToolEvent } from '../../../events'; +import { DispatchUiEvent } from '../../../hooks'; import { useHelpContext } from '../HelpContext'; export const HelpIndexView: FC<{}> = props => @@ -21,12 +19,12 @@ export const HelpIndexView: FC<{}> = props => const onRequestMySanctionStatusClick = useCallback(() => { - SendMessageHook(new GetCfhStatusMessageComposer(false)); + SendMessageComposer(new GetCfhStatusMessageComposer(false)); }, []); const onNewHelpRequestClick = useCallback(() => { - dispatchUiEvent(new GuideToolEvent(GuideToolEvent.CREATE_HELP_REQUEST)); + DispatchUiEvent(new GuideToolEvent(GuideToolEvent.CREATE_HELP_REQUEST)); }, []); return ( diff --git a/src/components/help/views/SanctionStatusView.tsx b/src/components/help/views/SanctionStatusView.tsx index 9419f739..ed0d2e55 100644 --- a/src/components/help/views/SanctionStatusView.tsx +++ b/src/components/help/views/SanctionStatusView.tsx @@ -2,7 +2,7 @@ import { SanctionStatusEvent, SanctionStatusMessageParser } from '@nitrots/nitro import { FC, useCallback, useState } from 'react'; import { LocalizeText } from '../../../api'; import { Base, Button, Column, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../common'; -import { CreateMessageHook } from '../../../hooks'; +import { UseMessageEventHook } from '../../../hooks'; export const SanctionSatusView:FC<{}> = props => { @@ -17,7 +17,7 @@ export const SanctionSatusView:FC<{}> = props => setSanctionInfo(parser); }, []); - CreateMessageHook(SanctionStatusEvent, onSanctionStatusEvent); + UseMessageEventHook(SanctionStatusEvent, onSanctionStatusEvent); const sanctionLocalization = useCallback((param: string, sanctionName: string, length?: number) => { diff --git a/src/components/help/views/name-change/NameChangeConfirmationView.tsx b/src/components/help/views/name-change/NameChangeConfirmationView.tsx index 6a91d4c2..6531de59 100644 --- a/src/components/help/views/name-change/NameChangeConfirmationView.tsx +++ b/src/components/help/views/name-change/NameChangeConfirmationView.tsx @@ -1,7 +1,7 @@ import { ChangeUserNameMessageComposer, UserNameChangeMessageEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useState } from 'react'; -import { GetSessionDataManager, LocalizeText } from '../../../../api'; -import { CreateMessageHook, SendMessageHook } from '../../../../hooks'; +import { GetSessionDataManager, LocalizeText, SendMessageComposer } from '../../../../api'; +import { UseMessageEventHook } from '../../../../hooks'; import { NameChangeLayoutViewProps } from './NameChangeView.types'; export const NameChangeConfirmationView:FC = props => @@ -21,14 +21,14 @@ export const NameChangeConfirmationView:FC = props => onAction('close'); }, [ onAction ]); - CreateMessageHook(UserNameChangeMessageEvent, onUserNameChangeMessageEvent); + UseMessageEventHook(UserNameChangeMessageEvent, onUserNameChangeMessageEvent); const confirm = useCallback(() => { if(isConfirming) return; setIsConfirming(true); - SendMessageHook(new ChangeUserNameMessageComposer(username)); + SendMessageComposer(new ChangeUserNameMessageComposer(username)); }, [ isConfirming, username ]); return ( diff --git a/src/components/help/views/name-change/NameChangeInputView.tsx b/src/components/help/views/name-change/NameChangeInputView.tsx index 3e1b3d12..c394c6e0 100644 --- a/src/components/help/views/name-change/NameChangeInputView.tsx +++ b/src/components/help/views/name-change/NameChangeInputView.tsx @@ -1,7 +1,7 @@ import { CheckUserNameMessageComposer, CheckUserNameResultMessageEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useState } from 'react'; -import { LocalizeText } from '../../../../api'; -import { CreateMessageHook, SendMessageHook } from '../../../../hooks'; +import { LocalizeText, SendMessageComposer } from '../../../../api'; +import { UseMessageEventHook } from '../../../../hooks'; import { NameChangeLayoutViewProps } from './NameChangeView.types'; const AVAILABLE: number = 0; @@ -52,7 +52,7 @@ export const NameChangeInputView:FC = props => } }, []); - CreateMessageHook(CheckUserNameResultMessageEvent, onCheckUserNameResultMessageEvent); + UseMessageEventHook(CheckUserNameResultMessageEvent, onCheckUserNameResultMessageEvent); const check = useCallback(() => { @@ -63,7 +63,7 @@ export const NameChangeInputView:FC = props => setErrorCode(null); setIsChecking(true); - SendMessageHook(new CheckUserNameMessageComposer(newUsername)); + SendMessageComposer(new CheckUserNameMessageComposer(newUsername)); }, [ newUsername ]); const handleUsernameChange = useCallback((username: string) => diff --git a/src/components/help/views/name-change/NameChangeView.tsx b/src/components/help/views/name-change/NameChangeView.tsx index ee97de8f..feccefc3 100644 --- a/src/components/help/views/name-change/NameChangeView.tsx +++ b/src/components/help/views/name-change/NameChangeView.tsx @@ -2,7 +2,7 @@ import { FC, useCallback, useMemo, useState } from 'react'; import { LocalizeText } from '../../../../api'; import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../common'; import { HelpNameChangeEvent } from '../../../../events'; -import { useUiEvent } from '../../../../hooks'; +import { UseUiEvent } from '../../../../hooks'; import { NameChangeConfirmationView } from './NameChangeConfirmationView'; import { NameChangeInitView } from './NameChangeInitView'; import { NameChangeInputView } from './NameChangeInputView'; @@ -23,7 +23,7 @@ export const NameChangeView:FC<{}> = props => setIsVisible(true); }, []); - useUiEvent(HelpNameChangeEvent.INIT, onHelpNameChangeEvent); + UseUiEvent(HelpNameChangeEvent.INIT, onHelpNameChangeEvent); const onAction = useCallback((action: string, value?: string) => { diff --git a/src/components/inventory/InventoryMessageHandler.tsx b/src/components/inventory/InventoryMessageHandler.tsx index 1cef493b..26155cf3 100644 --- a/src/components/inventory/InventoryMessageHandler.tsx +++ b/src/components/inventory/InventoryMessageHandler.tsx @@ -1,10 +1,10 @@ import { AdvancedMap, BadgePointLimitsEvent, BadgeReceivedEvent, BadgesEvent, BotAddedToInventoryEvent, BotInventoryMessageEvent, BotRemovedFromInventoryEvent, FurnitureListAddOrUpdateEvent, FurnitureListEvent, FurnitureListInvalidateEvent, FurnitureListItemParser, FurnitureListRemovedEvent, FurniturePostItPlacedEvent, PetAddedToInventoryEvent, PetData, PetInventoryEvent, PetRemovedFromInventory, RequestBadgesComposer, TradingAcceptEvent, TradingCloseEvent, TradingCompletedEvent, TradingConfirmationEvent, TradingListItemEvent, TradingNotOpenEvent, TradingOpenEvent, TradingOpenFailedEvent, TradingOtherNotAllowedEvent, TradingYouAreNotAllowedEvent, UnseenItemsEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback } from 'react'; -import { GetLocalization, GetRoomSession, GetSessionDataManager, LocalizeText } from '../../api'; +import { GetLocalization, GetRoomSession, GetSessionDataManager, LocalizeText, SendMessageComposer } from '../../api'; import { InventoryBadgesUpdatedEvent } from '../../events'; import { InventoryBadgesRequestEvent } from '../../events/inventory/InventoryBadgesRequestEvent'; -import { dispatchUiEvent, useUiEvent } from '../../hooks'; -import { CreateMessageHook, SendMessageHook } from '../../hooks/messages/message-event'; +import { DispatchUiEvent, UseUiEvent } from '../../hooks'; +import { UseMessageEventHook } from '../../hooks/messages/UseMessageEventHook'; import { NotificationUtilities } from '../../views/notification-center/common/NotificationUtilities'; import { mergeFurniFragments } from './common/FurnitureUtilities'; import { mergePetFragments } from './common/PetUtilities'; @@ -326,45 +326,45 @@ export const InventoryMessageHandler: FC<{}> = props => for(const data of parser.data) GetLocalization().setBadgePointLimit(data.badgeId, data.limit); }, []); - CreateMessageHook(FurnitureListAddOrUpdateEvent, onFurnitureListAddOrUpdateEvent); - CreateMessageHook(FurnitureListEvent, onFurnitureListEvent); - CreateMessageHook(FurnitureListInvalidateEvent, onFurnitureListInvalidateEvent); - CreateMessageHook(FurnitureListRemovedEvent, onFurnitureListRemovedEvent); - CreateMessageHook(FurniturePostItPlacedEvent, onFurniturePostItPlacedEvent); - CreateMessageHook(BotInventoryMessageEvent, onBotInventoryMessageEvent); - CreateMessageHook(BotRemovedFromInventoryEvent, onBotRemovedFromInventoryEvent); - CreateMessageHook(BotAddedToInventoryEvent, onBotAddedToInventoryEvent); - CreateMessageHook(PetInventoryEvent, onPetInventoryEvent); - CreateMessageHook(PetRemovedFromInventory, onPetRemovedFromInventory); - CreateMessageHook(PetAddedToInventoryEvent, onPetAddedToInventoryEvent); - CreateMessageHook(BadgesEvent, onBadgesEvent); - CreateMessageHook(BadgeReceivedEvent, onBadgeReceivedEvent); - CreateMessageHook(TradingAcceptEvent, onTradingAcceptEvent); - CreateMessageHook(TradingCloseEvent, onTradingCloseEvent); - CreateMessageHook(TradingCompletedEvent, onTradingCompletedEvent); - CreateMessageHook(TradingConfirmationEvent, onTradingConfirmationEvent); - CreateMessageHook(TradingListItemEvent, onTradingListItemEvent); - CreateMessageHook(TradingNotOpenEvent, onTradingNotOpenEvent); - CreateMessageHook(TradingOpenEvent, onTradingOpenEvent); - CreateMessageHook(TradingOpenFailedEvent, onTradingOpenFailedEvent); - CreateMessageHook(TradingOtherNotAllowedEvent, onTradingOtherNotAllowedEvent); - CreateMessageHook(TradingYouAreNotAllowedEvent, onTradingYouAreNotAllowedEvent); - CreateMessageHook(UnseenItemsEvent, onUnseenItemsEvent); - CreateMessageHook(BadgePointLimitsEvent, onBadgePointLimitsEvent); + UseMessageEventHook(FurnitureListAddOrUpdateEvent, onFurnitureListAddOrUpdateEvent); + UseMessageEventHook(FurnitureListEvent, onFurnitureListEvent); + UseMessageEventHook(FurnitureListInvalidateEvent, onFurnitureListInvalidateEvent); + UseMessageEventHook(FurnitureListRemovedEvent, onFurnitureListRemovedEvent); + UseMessageEventHook(FurniturePostItPlacedEvent, onFurniturePostItPlacedEvent); + UseMessageEventHook(BotInventoryMessageEvent, onBotInventoryMessageEvent); + UseMessageEventHook(BotRemovedFromInventoryEvent, onBotRemovedFromInventoryEvent); + UseMessageEventHook(BotAddedToInventoryEvent, onBotAddedToInventoryEvent); + UseMessageEventHook(PetInventoryEvent, onPetInventoryEvent); + UseMessageEventHook(PetRemovedFromInventory, onPetRemovedFromInventory); + UseMessageEventHook(PetAddedToInventoryEvent, onPetAddedToInventoryEvent); + UseMessageEventHook(BadgesEvent, onBadgesEvent); + UseMessageEventHook(BadgeReceivedEvent, onBadgeReceivedEvent); + UseMessageEventHook(TradingAcceptEvent, onTradingAcceptEvent); + UseMessageEventHook(TradingCloseEvent, onTradingCloseEvent); + UseMessageEventHook(TradingCompletedEvent, onTradingCompletedEvent); + UseMessageEventHook(TradingConfirmationEvent, onTradingConfirmationEvent); + UseMessageEventHook(TradingListItemEvent, onTradingListItemEvent); + UseMessageEventHook(TradingNotOpenEvent, onTradingNotOpenEvent); + UseMessageEventHook(TradingOpenEvent, onTradingOpenEvent); + UseMessageEventHook(TradingOpenFailedEvent, onTradingOpenFailedEvent); + UseMessageEventHook(TradingOtherNotAllowedEvent, onTradingOtherNotAllowedEvent); + UseMessageEventHook(TradingYouAreNotAllowedEvent, onTradingYouAreNotAllowedEvent); + UseMessageEventHook(UnseenItemsEvent, onUnseenItemsEvent); + UseMessageEventHook(BadgePointLimitsEvent, onBadgePointLimitsEvent); const onInventoryBadgesRequestEvent = useCallback((event: InventoryBadgesRequestEvent) => { if(badgeState.needsBadgeUpdate) { - SendMessageHook(new RequestBadgesComposer()); + SendMessageComposer(new RequestBadgesComposer()); return; } - dispatchUiEvent(new InventoryBadgesUpdatedEvent(InventoryBadgesUpdatedEvent.BADGES_UPDATED, badgeState.badges)); + DispatchUiEvent(new InventoryBadgesUpdatedEvent(InventoryBadgesUpdatedEvent.BADGES_UPDATED, badgeState.badges)); }, [ badgeState ]) - useUiEvent(InventoryBadgesRequestEvent.REQUEST_BADGES, onInventoryBadgesRequestEvent); + UseUiEvent(InventoryBadgesRequestEvent.REQUEST_BADGES, onInventoryBadgesRequestEvent); return null; } diff --git a/src/components/inventory/InventoryView.tsx b/src/components/inventory/InventoryView.tsx index a2ed38d3..e7d30914 100644 --- a/src/components/inventory/InventoryView.tsx +++ b/src/components/inventory/InventoryView.tsx @@ -1,12 +1,9 @@ import { IRoomSession, RoomEngineObjectEvent, RoomEngineObjectPlacedEvent, RoomPreviewer, RoomSessionEvent, TradingCancelComposer, TradingCloseComposer, TradingOpenComposer } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useReducer, useState } from 'react'; -import { GetRoomEngine, LocalizeText } from '../../api'; +import { GetRoomEngine, LocalizeText, SendMessageComposer } from '../../api'; import { NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../common'; import { InventoryBadgesUpdatedEvent, InventoryEvent, InventoryTradeRequestEvent } from '../../events'; -import { useRoomEngineEvent } from '../../hooks/events/nitro/room/room-engine-event'; -import { useRoomSessionManagerEvent } from '../../hooks/events/nitro/session/room-session-manager-event'; -import { dispatchUiEvent, useUiEvent } from '../../hooks/events/ui/ui-event'; -import { SendMessageHook } from '../../hooks/messages'; +import { DispatchUiEvent, UseRoomEngineEvent, UseRoomSessionManagerEvent, UseUiEvent } from '../../hooks'; import { isObjectMoverRequested, setObjectMoverRequested } from './common/InventoryUtilities'; import { TradeState } from './common/TradeState'; import { IUnseenItemTracker } from './common/unseen/IUnseenItemTracker'; @@ -50,10 +47,10 @@ export const InventoryView: FC<{}> = props => switch(furnitureState.tradeData.state) { case TradeState.TRADING_STATE_RUNNING: - SendMessageHook(new TradingCloseComposer()); + SendMessageComposer(new TradingCloseComposer()); return; default: - SendMessageHook(new TradingCancelComposer()); + SendMessageComposer(new TradingCancelComposer()); return; } } @@ -88,15 +85,15 @@ export const InventoryView: FC<{}> = props => case InventoryTradeRequestEvent.REQUEST_TRADE: { const tradeEvent = (event as InventoryTradeRequestEvent); - SendMessageHook(new TradingOpenComposer(tradeEvent.objectId)); + SendMessageComposer(new TradingOpenComposer(tradeEvent.objectId)); } } }, [ isVisible, close ]); - useUiEvent(InventoryEvent.SHOW_INVENTORY, onInventoryEvent); - useUiEvent(InventoryEvent.HIDE_INVENTORY, onInventoryEvent); - useUiEvent(InventoryEvent.TOGGLE_INVENTORY, onInventoryEvent); - useUiEvent(InventoryTradeRequestEvent.REQUEST_TRADE, onInventoryEvent); + UseUiEvent(InventoryEvent.SHOW_INVENTORY, onInventoryEvent); + UseUiEvent(InventoryEvent.HIDE_INVENTORY, onInventoryEvent); + UseUiEvent(InventoryEvent.TOGGLE_INVENTORY, onInventoryEvent); + UseUiEvent(InventoryTradeRequestEvent.REQUEST_TRADE, onInventoryEvent); const onRoomEngineObjectPlacedEvent = useCallback((event: RoomEngineObjectPlacedEvent) => { @@ -107,7 +104,7 @@ export const InventoryView: FC<{}> = props => if(!event.placedInRoom) setIsVisible(true); }, []); - useRoomEngineEvent(RoomEngineObjectEvent.PLACED, onRoomEngineObjectPlacedEvent); + UseRoomEngineEvent(RoomEngineObjectEvent.PLACED, onRoomEngineObjectPlacedEvent); const onRoomSessionEvent = useCallback((event: RoomSessionEvent) => { @@ -123,8 +120,8 @@ export const InventoryView: FC<{}> = props => } }, []); - useRoomSessionManagerEvent(RoomSessionEvent.CREATED, onRoomSessionEvent); - useRoomSessionManagerEvent(RoomSessionEvent.ENDED, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionEvent.CREATED, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionEvent.ENDED, onRoomSessionEvent); const resetTrackerForTab = useCallback((name: string) => { @@ -192,7 +189,7 @@ export const InventoryView: FC<{}> = props => { if(!badgeState.badges) return; - dispatchUiEvent(new InventoryBadgesUpdatedEvent(InventoryBadgesUpdatedEvent.BADGES_UPDATED, badgeState.badges)); + DispatchUiEvent(new InventoryBadgesUpdatedEvent(InventoryBadgesUpdatedEvent.BADGES_UPDATED, badgeState.badges)); }, [ badgeState.badges ]); return ( diff --git a/src/components/inventory/common/BotUtilities.ts b/src/components/inventory/common/BotUtilities.ts index 6ee76558..590c0e66 100644 --- a/src/components/inventory/common/BotUtilities.ts +++ b/src/components/inventory/common/BotUtilities.ts @@ -1,7 +1,7 @@ import { BotData, RoomObjectCategory, RoomObjectPlacementSource, RoomObjectType } from '@nitrots/nitro-renderer'; import { GetRoomEngine, GetRoomSessionManager } from '../../../api'; import { InventoryEvent } from '../../../events'; -import { dispatchUiEvent } from '../../../hooks/events/ui/ui-event'; +import { DispatchUiEvent } from '../../../hooks'; import { BotItem } from './BotItem'; import { getPlacingItemId, setObjectMoverRequested, setPlacingItemId } from './InventoryUtilities'; import { IUnseenItemTracker } from './unseen/IUnseenItemTracker'; @@ -27,7 +27,7 @@ export function attemptBotPlacement(botItem: BotItem, flag: boolean = false): bo if(!session || !session.isRoomOwner) return false; - dispatchUiEvent(new InventoryEvent(InventoryEvent.HIDE_INVENTORY)); + DispatchUiEvent(new InventoryEvent(InventoryEvent.HIDE_INVENTORY)); if(GetRoomEngine().processRoomObjectPlacement(RoomObjectPlacementSource.INVENTORY, -(botData.id), RoomObjectCategory.UNIT, RoomObjectType.RENTABLE_BOT, botData.figure)) { @@ -98,7 +98,7 @@ export function removeBotItemById(id: number, set: BotItem[]): BotItem { cancelRoomObjectPlacement(); - setTimeout(() => dispatchUiEvent(new InventoryEvent(InventoryEvent.SHOW_INVENTORY)), 1); + setTimeout(() => DispatchUiEvent(new InventoryEvent(InventoryEvent.SHOW_INVENTORY)), 1); } set.splice(index, 1); diff --git a/src/components/inventory/common/FurnitureUtilities.ts b/src/components/inventory/common/FurnitureUtilities.ts index 46ba4b7d..15bbe5e8 100644 --- a/src/components/inventory/common/FurnitureUtilities.ts +++ b/src/components/inventory/common/FurnitureUtilities.ts @@ -1,9 +1,7 @@ import { FurnitureListItemParser, FurniturePlacePaintComposer, IObjectData, RoomObjectCategory, RoomObjectPlacementSource } from '@nitrots/nitro-renderer'; -import { GetRoomEngine } from '../../../api'; -import { InventoryEvent } from '../../../events'; -import { CatalogPostMarketplaceOfferEvent } from '../../../events/catalog/CatalogPostMarketplaceOfferEvent'; -import { dispatchUiEvent } from '../../../hooks/events/ui/ui-event'; -import { SendMessageHook } from '../../../hooks/messages/message-event'; +import { GetRoomEngine, SendMessageComposer } from '../../../api'; +import { CatalogPostMarketplaceOfferEvent, InventoryEvent } from '../../../events'; +import { DispatchUiEvent } from '../../../hooks'; import { FurniCategory } from './FurniCategory'; import { FurnitureItem } from './FurnitureItem'; import { GroupItem } from './GroupItem'; @@ -23,13 +21,13 @@ export function attemptItemPlacement(groupItem: GroupItem, flag: boolean = false { if(flag) return false; - SendMessageHook(new FurniturePlacePaintComposer(item.id)); + SendMessageComposer(new FurniturePlacePaintComposer(item.id)); return false; } else { - dispatchUiEvent(new InventoryEvent(InventoryEvent.HIDE_INVENTORY)); + DispatchUiEvent(new InventoryEvent(InventoryEvent.HIDE_INVENTORY)); let category = 0; let isMoving = false; @@ -64,7 +62,7 @@ export function attemptPlaceMarketplaceOffer(groupItem: GroupItem): boolean if(!item.sellable) return false; - dispatchUiEvent(new CatalogPostMarketplaceOfferEvent(item)); + DispatchUiEvent(new CatalogPostMarketplaceOfferEvent(item)); } function cancelRoomObjectPlacement(): void @@ -180,7 +178,7 @@ export function removeFurniItemById(id: number, set: GroupItem[]): GroupItem if(!attemptItemPlacement(group)) { - setTimeout(() => dispatchUiEvent(new InventoryEvent(InventoryEvent.SHOW_INVENTORY)), 1); + setTimeout(() => DispatchUiEvent(new InventoryEvent(InventoryEvent.SHOW_INVENTORY)), 1); } } diff --git a/src/components/inventory/common/PetUtilities.ts b/src/components/inventory/common/PetUtilities.ts index 792963e8..02f5c096 100644 --- a/src/components/inventory/common/PetUtilities.ts +++ b/src/components/inventory/common/PetUtilities.ts @@ -1,7 +1,7 @@ import { PetData, RoomObjectCategory, RoomObjectPlacementSource, RoomObjectType } from '@nitrots/nitro-renderer'; import { GetRoomEngine, GetRoomSessionManager } from '../../../api'; import { InventoryEvent } from '../../../events'; -import { dispatchUiEvent } from '../../../hooks/events/ui/ui-event'; +import { DispatchUiEvent } from '../../../hooks'; import { getPlacingItemId, setObjectMoverRequested, setPlacingItemId } from './InventoryUtilities'; import { PetItem } from './PetItem'; import { IUnseenItemTracker } from './unseen/IUnseenItemTracker'; @@ -32,7 +32,7 @@ export function attemptPetPlacement(petItem: PetItem, flag: boolean = false): bo if(!session.allowPets) return false; } - dispatchUiEvent(new InventoryEvent(InventoryEvent.HIDE_INVENTORY)); + DispatchUiEvent(new InventoryEvent(InventoryEvent.HIDE_INVENTORY)); if(GetRoomEngine().processRoomObjectPlacement(RoomObjectPlacementSource.INVENTORY, -(petData.id), RoomObjectCategory.UNIT, RoomObjectType.PET, petData.figureData.figuredata)) { @@ -117,7 +117,7 @@ export function removePetItemById(id: number, set: PetItem[]): PetItem { cancelRoomObjectPlacement(); - setTimeout(() => dispatchUiEvent(new InventoryEvent(InventoryEvent.SHOW_INVENTORY)), 1); + setTimeout(() => DispatchUiEvent(new InventoryEvent(InventoryEvent.SHOW_INVENTORY)), 1); } set.splice(index, 1); diff --git a/src/components/inventory/common/unseen/UnseenItemTracker.ts b/src/components/inventory/common/unseen/UnseenItemTracker.ts index a647f987..660d5ba8 100644 --- a/src/components/inventory/common/unseen/UnseenItemTracker.ts +++ b/src/components/inventory/common/unseen/UnseenItemTracker.ts @@ -1,6 +1,7 @@ import { UnseenResetCategoryComposer, UnseenResetItemsComposer } from '@nitrots/nitro-renderer'; +import { SendMessageComposer } from '../../../../api'; import { UnseenItemTrackerUpdateEvent } from '../../../../events'; -import { dispatchUiEvent, SendMessageHook } from '../../../../hooks'; +import { DispatchUiEvent } from '../../../../hooks'; import { IUnseenItemTracker } from './IUnseenItemTracker'; export class UnseenItemTracker implements IUnseenItemTracker @@ -130,16 +131,16 @@ export class UnseenItemTracker implements IUnseenItemTracker private dispatchUpdateEvent(): void { - dispatchUiEvent(new UnseenItemTrackerUpdateEvent(this.getFullCount())); + DispatchUiEvent(new UnseenItemTrackerUpdateEvent(this.getFullCount())); } private sendResetCategoryMessage(category: number): void { - SendMessageHook(new UnseenResetCategoryComposer(category)); + SendMessageComposer(new UnseenResetCategoryComposer(category)); } private sendResetItemsMessage(category: number, itemIds: number[]): void { - SendMessageHook(new UnseenResetItemsComposer(category, ...itemIds)); + SendMessageComposer(new UnseenResetItemsComposer(category, ...itemIds)); } } diff --git a/src/components/inventory/reducers/InventoryBadgeReducer.tsx b/src/components/inventory/reducers/InventoryBadgeReducer.tsx index feac6450..b8de1d72 100644 --- a/src/components/inventory/reducers/InventoryBadgeReducer.tsx +++ b/src/components/inventory/reducers/InventoryBadgeReducer.tsx @@ -1,6 +1,6 @@ import { SetActivatedBadgesComposer } from '@nitrots/nitro-renderer'; import { Reducer } from 'react'; -import { SendMessageHook } from '../../../hooks/messages/message-event'; +import { SendMessageComposer } from '../../../api'; export interface IInventoryBadgeState { @@ -102,7 +102,7 @@ export const InventoryBadgeReducer: Reducer = props => } }); - SendMessageHook(new RequestBadgesComposer()); + SendMessageComposer(new RequestBadgesComposer()); } else { diff --git a/src/components/inventory/views/bot/InventoryBotItemView.tsx b/src/components/inventory/views/bot/InventoryBotItemView.tsx index ee7c3682..0e5157f7 100644 --- a/src/components/inventory/views/bot/InventoryBotItemView.tsx +++ b/src/components/inventory/views/bot/InventoryBotItemView.tsx @@ -1,6 +1,6 @@ import { MouseEventType } from '@nitrots/nitro-renderer'; import { FC, MouseEvent, useEffect, useState } from 'react'; -import { LayoutGridItem } from '../../../../common/layout/LayoutGridItem'; +import { LayoutGridItem } from '../../../../common'; import { AvatarImageView } from '../../../../views/shared/avatar-image/AvatarImageView'; import { BotItem } from '../../common/BotItem'; import { attemptBotPlacement } from '../../common/BotUtilities'; diff --git a/src/components/inventory/views/bot/InventoryBotView.tsx b/src/components/inventory/views/bot/InventoryBotView.tsx index 5a37f30f..d36fc9b6 100644 --- a/src/components/inventory/views/bot/InventoryBotView.tsx +++ b/src/components/inventory/views/bot/InventoryBotView.tsx @@ -1,12 +1,7 @@ import { GetBotInventoryComposer, IRoomSession, RoomObjectVariable, RoomPreviewer } from '@nitrots/nitro-renderer'; import { FC, useEffect } from 'react'; -import { GetRoomEngine, LocalizeText } from '../../../../api'; -import { AutoGrid } from '../../../../common/AutoGrid'; -import { Button } from '../../../../common/Button'; -import { Column } from '../../../../common/Column'; -import { Grid } from '../../../../common/Grid'; -import { Text } from '../../../../common/Text'; -import { SendMessageHook } from '../../../../hooks/messages/message-event'; +import { GetRoomEngine, LocalizeText, SendMessageComposer } from '../../../../api'; +import { AutoGrid, Button, Column, Grid, Text } from '../../../../common'; import { RoomPreviewerView } from '../../../../views/shared/room-previewer/RoomPreviewerView'; import { attemptBotPlacement } from '../../common/BotUtilities'; import { useInventoryContext } from '../../InventoryContext'; @@ -37,7 +32,7 @@ export const InventoryBotView: FC = props => } }); - SendMessageHook(new GetBotInventoryComposer()); + SendMessageComposer(new GetBotInventoryComposer()); } else { diff --git a/src/components/inventory/views/furniture/InventoryFurnitureView.tsx b/src/components/inventory/views/furniture/InventoryFurnitureView.tsx index d266e1d6..4cbdf1d6 100644 --- a/src/components/inventory/views/furniture/InventoryFurnitureView.tsx +++ b/src/components/inventory/views/furniture/InventoryFurnitureView.tsx @@ -1,12 +1,7 @@ import { FurnitureListComposer, IRoomSession, RoomObjectVariable, RoomPreviewer, Vector3d } from '@nitrots/nitro-renderer'; import { FC, useEffect, useState } from 'react'; -import { GetRoomEngine, GetSessionDataManager, LocalizeText } from '../../../../api'; -import { AutoGrid } from '../../../../common/AutoGrid'; -import { Button } from '../../../../common/Button'; -import { Column } from '../../../../common/Column'; -import { Grid } from '../../../../common/Grid'; -import { Text } from '../../../../common/Text'; -import { SendMessageHook } from '../../../../hooks/messages'; +import { GetRoomEngine, GetSessionDataManager, LocalizeText, SendMessageComposer } from '../../../../api'; +import { AutoGrid, Button, Column, Grid, Text } from '../../../../common'; import { LimitedEditionCompactPlateView } from '../../../../views/shared/limited-edition/LimitedEditionCompactPlateView'; import { RarityLevelView } from '../../../../views/shared/rarity-level/RarityLevelView'; import { RoomPreviewerView } from '../../../../views/shared/room-previewer/RoomPreviewerView'; @@ -43,7 +38,7 @@ export const InventoryFurnitureView: FC = props => } }); - SendMessageHook(new FurnitureListComposer()); + SendMessageComposer(new FurnitureListComposer()); } else { diff --git a/src/components/inventory/views/pet/InventoryPetItemView.tsx b/src/components/inventory/views/pet/InventoryPetItemView.tsx index 22b5bd94..d8a49f95 100644 --- a/src/components/inventory/views/pet/InventoryPetItemView.tsx +++ b/src/components/inventory/views/pet/InventoryPetItemView.tsx @@ -1,6 +1,6 @@ import { MouseEventType } from '@nitrots/nitro-renderer'; import { FC, MouseEvent, useEffect, useState } from 'react'; -import { LayoutGridItem } from '../../../../common/layout/LayoutGridItem'; +import { LayoutGridItem } from '../../../../common'; import { PetImageView } from '../../../../views/shared/pet-image/PetImageView'; import { PetItem } from '../../common/PetItem'; import { attemptPetPlacement } from '../../common/PetUtilities'; diff --git a/src/components/inventory/views/pet/InventoryPetView.tsx b/src/components/inventory/views/pet/InventoryPetView.tsx index 411e9cb8..e76029ce 100644 --- a/src/components/inventory/views/pet/InventoryPetView.tsx +++ b/src/components/inventory/views/pet/InventoryPetView.tsx @@ -1,12 +1,7 @@ import { IRoomSession, RequestPetsComposer, RoomObjectVariable, RoomPreviewer } from '@nitrots/nitro-renderer'; import { FC, useEffect } from 'react'; -import { GetRoomEngine, LocalizeText } from '../../../../api'; -import { AutoGrid } from '../../../../common/AutoGrid'; -import { Button } from '../../../../common/Button'; -import { Column } from '../../../../common/Column'; -import { Grid } from '../../../../common/Grid'; -import { Text } from '../../../../common/Text'; -import { SendMessageHook } from '../../../../hooks/messages/message-event'; +import { GetRoomEngine, LocalizeText, SendMessageComposer } from '../../../../api'; +import { AutoGrid, Button, Column, Grid, Text } from '../../../../common'; import { RoomPreviewerView } from '../../../../views/shared/room-previewer/RoomPreviewerView'; import { attemptPetPlacement } from '../../common/PetUtilities'; import { useInventoryContext } from '../../InventoryContext'; @@ -37,7 +32,7 @@ export const InventoryPetView: FC = props => } }); - SendMessageHook(new RequestPetsComposer()); + SendMessageComposer(new RequestPetsComposer()); } else { diff --git a/src/components/inventory/views/trade/InventoryTradeView.tsx b/src/components/inventory/views/trade/InventoryTradeView.tsx index cccb32df..0acfba12 100644 --- a/src/components/inventory/views/trade/InventoryTradeView.tsx +++ b/src/components/inventory/views/trade/InventoryTradeView.tsx @@ -1,16 +1,8 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { FurnitureListComposer, IObjectData, TradingAcceptComposer, TradingConfirmationComposer, TradingListAddItemComposer, TradingListAddItemsComposer, TradingListItemRemoveComposer, TradingUnacceptComposer } from '@nitrots/nitro-renderer'; import { FC, useEffect, useState } from 'react'; -import { LocalizeText } from '../../../../api'; -import { AutoGrid } from '../../../../common/AutoGrid'; -import { Base } from '../../../../common/Base'; -import { Button } from '../../../../common/Button'; -import { Column } from '../../../../common/Column'; -import { Flex } from '../../../../common/Flex'; -import { Grid } from '../../../../common/Grid'; -import { LayoutGridItem } from '../../../../common/layout/LayoutGridItem'; -import { Text } from '../../../../common/Text'; -import { SendMessageHook } from '../../../../hooks/messages'; +import { LocalizeText, SendMessageComposer } from '../../../../api'; +import { AutoGrid, Base, Button, Column, Flex, Grid, LayoutGridItem, Text } from '../../../../common'; import { NotificationAlertType } from '../../../../views/notification-center/common/NotificationAlertType'; import { NotificationUtilities } from '../../../../views/notification-center/common/NotificationUtilities'; import { FurniCategory } from '../../common/FurniCategory'; @@ -93,7 +85,7 @@ export const InventoryTradeView: FC = props => { if(!coreItem.isGroupable && (itemIds.length)) { - SendMessageHook(new TradingListAddItemComposer(itemIds.pop())); + SendMessageComposer(new TradingListAddItemComposer(itemIds.pop())); } else { @@ -111,11 +103,11 @@ export const InventoryTradeView: FC = props => { if(tradeIds.length === 1) { - SendMessageHook(new TradingListAddItemComposer(tradeIds.pop())); + SendMessageComposer(new TradingListAddItemComposer(tradeIds.pop())); } else { - SendMessageHook(new TradingListAddItemsComposer(...tradeIds)); + SendMessageComposer(new TradingListAddItemsComposer(...tradeIds)); } } } @@ -132,7 +124,7 @@ export const InventoryTradeView: FC = props => if(!item) return; - SendMessageHook(new TradingListItemRemoveComposer(item.id)); + SendMessageComposer(new TradingListItemRemoveComposer(item.id)); } const progressTrade = () => @@ -147,15 +139,15 @@ export const InventoryTradeView: FC = props => if(tradeData.ownUser.accepts) { - SendMessageHook(new TradingUnacceptComposer()); + SendMessageComposer(new TradingUnacceptComposer()); } else { - SendMessageHook(new TradingAcceptComposer()); + SendMessageComposer(new TradingAcceptComposer()); } return; case TradeState.TRADING_STATE_CONFIRMING: - SendMessageHook(new TradingConfirmationComposer()); + SendMessageComposer(new TradingConfirmationComposer()); dispatchFurnitureState({ type: InventoryFurnitureActions.SET_TRADE_STATE, @@ -186,7 +178,7 @@ export const InventoryTradeView: FC = props => } }); - SendMessageHook(new FurnitureListComposer()); + SendMessageComposer(new FurnitureListComposer()); } }, [ needsFurniUpdate, groupItems, dispatchFurnitureState ]); diff --git a/src/components/main/MainView.tsx b/src/components/main/MainView.tsx index 2a6f8733..2aa7d0fb 100644 --- a/src/components/main/MainView.tsx +++ b/src/components/main/MainView.tsx @@ -2,7 +2,7 @@ import { HabboWebTools, RoomSessionEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; import { AddEventLinkTracker, GetCommunication, RemoveLinkEventTracker } from '../../api'; import { Base, TransitionAnimation, TransitionAnimationTypes } from '../../common'; -import { useRoomSessionManagerEvent } from '../../hooks/events/nitro/session/room-session-manager-event'; +import { UseRoomSessionManagerEvent } from '../../hooks'; import { CampaignView } from '../../views/campaign/CampaignView'; import { FloorplanEditorView } from '../../views/floorplan-editor/FloorplanEditorView'; import { FriendsView } from '../../views/friends/FriendsView'; @@ -45,8 +45,8 @@ export const MainView: FC<{}> = props => } }, []); - useRoomSessionManagerEvent(RoomSessionEvent.CREATED, onRoomSessionEvent); - useRoomSessionManagerEvent(RoomSessionEvent.ENDED, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionEvent.CREATED, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionEvent.ENDED, onRoomSessionEvent); const onLinkReceived = useCallback((link: string) => { diff --git a/src/components/mod-tools/ModToolsMessageHandler.tsx b/src/components/mod-tools/ModToolsMessageHandler.tsx index 82820610..f68f7df8 100644 --- a/src/components/mod-tools/ModToolsMessageHandler.tsx +++ b/src/components/mod-tools/ModToolsMessageHandler.tsx @@ -1,12 +1,8 @@ import { CfhSanctionMessageEvent, CfhTopicsInitEvent, IssueDeletedMessageEvent, IssueInfoMessageEvent, IssuePickFailedMessageEvent, ModeratorActionResultMessageEvent, ModeratorInitMessageEvent, ModeratorToolPreferencesEvent, RoomEngineEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback } from 'react'; -import { MODTOOLS_NEW_TICKET, PlaySound } from '../../api/utils/PlaySound'; -import { ModToolsEvent } from '../../events/mod-tools/ModToolsEvent'; -import { ModToolsOpenRoomChatlogEvent } from '../../events/mod-tools/ModToolsOpenRoomChatlogEvent'; -import { ModToolsOpenRoomInfoEvent } from '../../events/mod-tools/ModToolsOpenRoomInfoEvent'; -import { ModToolsOpenUserChatlogEvent } from '../../events/mod-tools/ModToolsOpenUserChatlogEvent'; -import { ModToolsOpenUserInfoEvent } from '../../events/mod-tools/ModToolsOpenUserInfoEvent'; -import { CreateMessageHook, useRoomEngineEvent, useUiEvent } from '../../hooks'; +import { MODTOOLS_NEW_TICKET, PlaySound } from '../../api'; +import { ModToolsEvent, ModToolsOpenRoomChatlogEvent, ModToolsOpenRoomInfoEvent, ModToolsOpenUserChatlogEvent, ModToolsOpenUserInfoEvent } from '../../events'; +import { UseMessageEventHook, UseRoomEngineEvent, UseUiEvent } from '../../hooks'; import { NotificationAlertType } from '../../views/notification-center/common/NotificationAlertType'; import { NotificationUtilities } from '../../views/notification-center/common/NotificationUtilities'; import { SetCfhCategories } from './common/GetCFHCategories'; @@ -152,14 +148,14 @@ export const ModToolsMessageHandler: FC<{}> = props => // todo: update sanction data }, []); - CreateMessageHook(ModeratorInitMessageEvent, onModeratorInitMessageEvent); - CreateMessageHook(IssueInfoMessageEvent, onIssueInfoMessageEvent); - CreateMessageHook(ModeratorToolPreferencesEvent, onModeratorToolPreferencesEvent); - CreateMessageHook(IssuePickFailedMessageEvent, onIssuePickFailedMessageEvent); - CreateMessageHook(IssueDeletedMessageEvent, onIssueDeletedMessageEvent); - CreateMessageHook(ModeratorActionResultMessageEvent, onModeratorActionResultMessageEvent); - CreateMessageHook(CfhTopicsInitEvent, onCfhTopicsInitEvent); - CreateMessageHook(CfhSanctionMessageEvent, onCfhSanctionMessageEvent); + UseMessageEventHook(ModeratorInitMessageEvent, onModeratorInitMessageEvent); + UseMessageEventHook(IssueInfoMessageEvent, onIssueInfoMessageEvent); + UseMessageEventHook(ModeratorToolPreferencesEvent, onModeratorToolPreferencesEvent); + UseMessageEventHook(IssuePickFailedMessageEvent, onIssuePickFailedMessageEvent); + UseMessageEventHook(IssueDeletedMessageEvent, onIssueDeletedMessageEvent); + UseMessageEventHook(ModeratorActionResultMessageEvent, onModeratorActionResultMessageEvent); + UseMessageEventHook(CfhTopicsInitEvent, onCfhTopicsInitEvent); + UseMessageEventHook(CfhSanctionMessageEvent, onCfhSanctionMessageEvent); const onRoomEngineEvent = useCallback((event: RoomEngineEvent) => { @@ -184,8 +180,8 @@ export const ModToolsMessageHandler: FC<{}> = props => } }, [ dispatchModToolsState ]); - useRoomEngineEvent(RoomEngineEvent.INITIALIZED, onRoomEngineEvent); - useRoomEngineEvent(RoomEngineEvent.DISPOSED, onRoomEngineEvent); + UseRoomEngineEvent(RoomEngineEvent.INITIALIZED, onRoomEngineEvent); + UseRoomEngineEvent(RoomEngineEvent.DISPOSED, onRoomEngineEvent); const onModToolsEvent = useCallback((event: ModToolsEvent) => { @@ -254,10 +250,10 @@ export const ModToolsMessageHandler: FC<{}> = props => } }, [openRooms, dispatchModToolsState, openRoomChatlogs, openUserInfo, openUserChatlogs]); - useUiEvent(ModToolsEvent.OPEN_ROOM_INFO, onModToolsEvent); - useUiEvent(ModToolsEvent.OPEN_ROOM_CHATLOG, onModToolsEvent); - useUiEvent(ModToolsEvent.OPEN_USER_INFO, onModToolsEvent); - useUiEvent(ModToolsEvent.OPEN_USER_CHATLOG, onModToolsEvent); + UseUiEvent(ModToolsEvent.OPEN_ROOM_INFO, onModToolsEvent); + UseUiEvent(ModToolsEvent.OPEN_ROOM_CHATLOG, onModToolsEvent); + UseUiEvent(ModToolsEvent.OPEN_USER_INFO, onModToolsEvent); + UseUiEvent(ModToolsEvent.OPEN_USER_CHATLOG, onModToolsEvent); return null; } diff --git a/src/components/mod-tools/ModToolsView.tsx b/src/components/mod-tools/ModToolsView.tsx index 0f3e57a9..07495e95 100644 --- a/src/components/mod-tools/ModToolsView.tsx +++ b/src/components/mod-tools/ModToolsView.tsx @@ -3,12 +3,8 @@ import { RoomEngineObjectEvent, RoomObjectCategory } from '@nitrots/nitro-render import { FC, useCallback, useReducer, useState } from 'react'; import { GetRoomSession } from '../../api'; import { Button, NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../common'; -import { ModToolsEvent } from '../../events/mod-tools/ModToolsEvent'; -import { ModToolsOpenRoomChatlogEvent } from '../../events/mod-tools/ModToolsOpenRoomChatlogEvent'; -import { ModToolsOpenRoomInfoEvent } from '../../events/mod-tools/ModToolsOpenRoomInfoEvent'; -import { ModToolsOpenUserInfoEvent } from '../../events/mod-tools/ModToolsOpenUserInfoEvent'; -import { useRoomEngineEvent } from '../../hooks/events'; -import { dispatchUiEvent, useUiEvent } from '../../hooks/events/ui/ui-event'; +import { ModToolsEvent, ModToolsOpenRoomChatlogEvent, ModToolsOpenRoomInfoEvent, ModToolsOpenUserInfoEvent } from '../../events'; +import { DispatchUiEvent, UseRoomEngineEvent, UseUiEvent } from '../../hooks'; import { ModToolsContextProvider } from './ModToolsContext'; import { ModToolsMessageHandler } from './ModToolsMessageHandler'; import { initialModTools, ModToolsActions, ModToolsReducer } from './reducers/ModToolsReducer'; @@ -43,9 +39,9 @@ export const ModToolsView: FC<{}> = props => } }, []); - useUiEvent(ModToolsEvent.SHOW_MOD_TOOLS, onModToolsEvent); - useUiEvent(ModToolsEvent.HIDE_MOD_TOOLS, onModToolsEvent); - useUiEvent(ModToolsEvent.TOGGLE_MOD_TOOLS, onModToolsEvent); + UseUiEvent(ModToolsEvent.SHOW_MOD_TOOLS, onModToolsEvent); + UseUiEvent(ModToolsEvent.HIDE_MOD_TOOLS, onModToolsEvent); + UseUiEvent(ModToolsEvent.TOGGLE_MOD_TOOLS, onModToolsEvent); const onRoomEngineObjectEvent = useCallback((event: RoomEngineObjectEvent) => { @@ -62,7 +58,7 @@ export const ModToolsView: FC<{}> = props => setSelectedUser({ userId: userData.webID, username: userData.name }); }, []); - useRoomEngineEvent(RoomEngineObjectEvent.SELECTED, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineObjectEvent.SELECTED, onRoomEngineObjectEvent); const handleClick = useCallback((action: string, value?: string) => { @@ -73,7 +69,7 @@ export const ModToolsView: FC<{}> = props => case 'toggle_room': { if(!openRooms) { - dispatchUiEvent(new ModToolsOpenRoomInfoEvent(currentRoomId)); + DispatchUiEvent(new ModToolsOpenRoomInfoEvent(currentRoomId)); return; } @@ -83,7 +79,7 @@ export const ModToolsView: FC<{}> = props => } else { - dispatchUiEvent(new ModToolsOpenRoomInfoEvent(currentRoomId)); + DispatchUiEvent(new ModToolsOpenRoomInfoEvent(currentRoomId)); } return; } @@ -104,7 +100,7 @@ export const ModToolsView: FC<{}> = props => case 'toggle_room_chatlog': { if(!openRoomChatlogs) { - dispatchUiEvent(new ModToolsOpenRoomChatlogEvent(currentRoomId)); + DispatchUiEvent(new ModToolsOpenRoomChatlogEvent(currentRoomId)); return; } @@ -114,7 +110,7 @@ export const ModToolsView: FC<{}> = props => } else { - dispatchUiEvent(new ModToolsOpenRoomChatlogEvent(currentRoomId)); + DispatchUiEvent(new ModToolsOpenRoomChatlogEvent(currentRoomId)); } return; } @@ -140,7 +136,7 @@ export const ModToolsView: FC<{}> = props => if(!openUserInfo) { - dispatchUiEvent(new ModToolsOpenUserInfoEvent(userId)); + DispatchUiEvent(new ModToolsOpenUserInfoEvent(userId)); return; } @@ -150,7 +146,7 @@ export const ModToolsView: FC<{}> = props => } else { - dispatchUiEvent(new ModToolsOpenUserInfoEvent(userId)); + DispatchUiEvent(new ModToolsOpenUserInfoEvent(userId)); } return; } diff --git a/src/components/mod-tools/views/chatlog/ChatlogView.tsx b/src/components/mod-tools/views/chatlog/ChatlogView.tsx index b6887dec..e0e4619d 100644 --- a/src/components/mod-tools/views/chatlog/ChatlogView.tsx +++ b/src/components/mod-tools/views/chatlog/ChatlogView.tsx @@ -1,10 +1,10 @@ import { ChatRecordData, UserProfileComposer } from '@nitrots/nitro-renderer'; import { CSSProperties, FC, Key, useCallback } from 'react'; import { AutoSizer, CellMeasurer, CellMeasurerCache, List, ListRowProps } from 'react-virtualized'; -import { TryVisitRoom } from '../../../../api'; +import { SendMessageComposer, TryVisitRoom } from '../../../../api'; import { Base, Button, Column, Flex, Grid, Text } from '../../../../common'; import { ModToolsOpenRoomInfoEvent } from '../../../../events/mod-tools/ModToolsOpenRoomInfoEvent'; -import { dispatchUiEvent, SendMessageHook } from '../../../../hooks'; +import { DispatchUiEvent } from '../../../../hooks'; interface ChatlogViewProps { @@ -29,7 +29,7 @@ export const ChatlogView: FC = props => > { chatlogEntry.timestamp } - SendMessageHook(new UserProfileComposer(chatlogEntry.userId)) }>{ chatlogEntry.userName } + SendMessageComposer(new UserProfileComposer(chatlogEntry.userId)) }>{ chatlogEntry.userName } { chatlogEntry.message } @@ -79,7 +79,7 @@ export const ChatlogView: FC = props => { !isRoomInfo && { chatlogEntry.timestamp } - SendMessageHook(new UserProfileComposer(chatlogEntry.userId)) }>{ chatlogEntry.userName } + SendMessageComposer(new UserProfileComposer(chatlogEntry.userId)) }>{ chatlogEntry.userName } { chatlogEntry.message } } @@ -109,7 +109,7 @@ export const ChatlogView: FC = props => - + ); diff --git a/src/components/mod-tools/views/room/ModToolsChatlogView.tsx b/src/components/mod-tools/views/room/ModToolsChatlogView.tsx index 4989e2db..5800c018 100644 --- a/src/components/mod-tools/views/room/ModToolsChatlogView.tsx +++ b/src/components/mod-tools/views/room/ModToolsChatlogView.tsx @@ -1,7 +1,8 @@ import { ChatRecordData, GetRoomChatlogMessageComposer, RoomChatlogEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; +import { SendMessageComposer } from '../../../../api'; import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../common'; -import { CreateMessageHook, SendMessageHook } from '../../../../hooks/messages'; +import { UseMessageEventHook } from '../../../../hooks'; import { ChatlogView } from '../chatlog/ChatlogView'; interface ModToolsChatlogViewProps @@ -24,11 +25,11 @@ export const ModToolsChatlogView: FC = props => setRoomChatlog(parser.data); }, [ roomId ]); - CreateMessageHook(RoomChatlogEvent, onModtoolRoomChatlogEvent); + UseMessageEventHook(RoomChatlogEvent, onModtoolRoomChatlogEvent); useEffect(() => { - SendMessageHook(new GetRoomChatlogMessageComposer(roomId)); + SendMessageComposer(new GetRoomChatlogMessageComposer(roomId)); }, [ roomId ]); if(!roomChatlog) return null; diff --git a/src/components/mod-tools/views/room/ModToolsRoomView.tsx b/src/components/mod-tools/views/room/ModToolsRoomView.tsx index 0bb66143..05428ff4 100644 --- a/src/components/mod-tools/views/room/ModToolsRoomView.tsx +++ b/src/components/mod-tools/views/room/ModToolsRoomView.tsx @@ -1,10 +1,9 @@ import { GetModeratorRoomInfoMessageComposer, ModerateRoomMessageComposer, ModeratorActionMessageComposer, ModeratorRoomInfoEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; -import { TryVisitRoom } from '../../../../api'; +import { SendMessageComposer, TryVisitRoom } from '../../../../api'; import { Button, Column, Flex, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../../common'; import { ModToolsOpenRoomChatlogEvent } from '../../../../events/mod-tools/ModToolsOpenRoomChatlogEvent'; -import { BatchUpdates, dispatchUiEvent } from '../../../../hooks'; -import { CreateMessageHook, SendMessageHook } from '../../../../hooks/messages'; +import { BatchUpdates, DispatchUiEvent, UseMessageEventHook } from '../../../../hooks'; interface ModToolsRoomViewProps { @@ -48,7 +47,7 @@ export const ModToolsRoomView: FC = props => }); }, [ roomId ]); - CreateMessageHook(ModeratorRoomInfoEvent, onModtoolRoomInfoEvent); + UseMessageEventHook(ModeratorRoomInfoEvent, onModtoolRoomInfoEvent); const handleClick = useCallback((action: string, value?: string) => { @@ -59,13 +58,13 @@ export const ModToolsRoomView: FC = props => case 'alert_only': if(message.trim().length === 0) return; - SendMessageHook(new ModeratorActionMessageComposer(ModeratorActionMessageComposer.ACTION_ALERT, message, '')); + SendMessageComposer(new ModeratorActionMessageComposer(ModeratorActionMessageComposer.ACTION_ALERT, message, '')); return; case 'send_message': if(message.trim().length === 0) return; - SendMessageHook(new ModeratorActionMessageComposer(ModeratorActionMessageComposer.ACTION_MESSAGE, message, '')); - SendMessageHook(new ModerateRoomMessageComposer(roomId, lockRoom ? 1 : 0, changeRoomName ? 1 : 0, kickUsers ? 1 : 0)) + SendMessageComposer(new ModeratorActionMessageComposer(ModeratorActionMessageComposer.ACTION_MESSAGE, message, '')); + SendMessageComposer(new ModerateRoomMessageComposer(roomId, lockRoom ? 1 : 0, changeRoomName ? 1 : 0, kickUsers ? 1 : 0)) return; } }, [ changeRoomName, kickUsers, lockRoom, message, roomId ]); @@ -74,7 +73,7 @@ export const ModToolsRoomView: FC = props => { if(infoRequested) return; - SendMessageHook(new GetModeratorRoomInfoMessageComposer(roomId)); + SendMessageComposer(new GetModeratorRoomInfoMessageComposer(roomId)); setInfoRequested(true); }, [ roomId, infoRequested, setInfoRequested ]); @@ -99,7 +98,7 @@ export const ModToolsRoomView: FC = props => - + diff --git a/src/components/mod-tools/views/tickets/CfhChatlogView.tsx b/src/components/mod-tools/views/tickets/CfhChatlogView.tsx index 2040bf37..553ab093 100644 --- a/src/components/mod-tools/views/tickets/CfhChatlogView.tsx +++ b/src/components/mod-tools/views/tickets/CfhChatlogView.tsx @@ -1,7 +1,8 @@ import { CfhChatlogData, CfhChatlogEvent, GetCfhChatlogMessageComposer } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; +import { SendMessageComposer } from '../../../../api'; import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../common'; -import { CreateMessageHook, SendMessageHook } from '../../../../hooks'; +import { UseMessageEventHook } from '../../../../hooks'; import { ChatlogView } from '../chatlog/ChatlogView'; interface CfhChatlogViewProps @@ -17,7 +18,7 @@ export const CfhChatlogView: FC = props => useEffect(() => { - SendMessageHook(new GetCfhChatlogMessageComposer(issueId)); + SendMessageComposer(new GetCfhChatlogMessageComposer(issueId)); }, [issueId]); const onCfhChatlogEvent = useCallback((event: CfhChatlogEvent) => @@ -29,7 +30,7 @@ export const CfhChatlogView: FC = props => setChatlogData(parser.data); }, [issueId]); - CreateMessageHook(CfhChatlogEvent, onCfhChatlogEvent); + UseMessageEventHook(CfhChatlogEvent, onCfhChatlogEvent); return ( diff --git a/src/components/mod-tools/views/tickets/ModToolsIssueInfoView.tsx b/src/components/mod-tools/views/tickets/ModToolsIssueInfoView.tsx index 66b34ca0..464a6085 100644 --- a/src/components/mod-tools/views/tickets/ModToolsIssueInfoView.tsx +++ b/src/components/mod-tools/views/tickets/ModToolsIssueInfoView.tsx @@ -1,9 +1,9 @@ import { CloseIssuesMessageComposer, ReleaseIssuesMessageComposer } from '@nitrots/nitro-renderer'; import { FC, useMemo, useState } from 'react'; -import { LocalizeText } from '../../../../api'; +import { LocalizeText, SendMessageComposer } from '../../../../api'; import { Button, Column, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../../common'; -import { ModToolsOpenUserInfoEvent } from '../../../../events/mod-tools/ModToolsOpenUserInfoEvent'; -import { dispatchUiEvent, SendMessageHook } from '../../../../hooks'; +import { ModToolsOpenUserInfoEvent } from '../../../../events'; +import { DispatchUiEvent } from '../../../../hooks'; import { getSourceName } from '../../common/IssueCategoryNames'; import { useModToolsContext } from '../../ModToolsContext'; import { CfhChatlogView } from './CfhChatlogView'; @@ -30,19 +30,19 @@ export const ModToolsIssueInfoView: FC = props => const releaseIssue = (issueId: number) => { - SendMessageHook(new ReleaseIssuesMessageComposer([ issueId ])); + SendMessageComposer(new ReleaseIssuesMessageComposer([ issueId ])); onIssueInfoClosed(issueId); } const closeIssue = (resolutionType: number) => { - SendMessageHook(new CloseIssuesMessageComposer([ issueId ], resolutionType)); + SendMessageComposer(new CloseIssuesMessageComposer([ issueId ], resolutionType)); onIssueInfoClosed(issueId) } - const openUserInfo = (userId: number) => dispatchUiEvent(new ModToolsOpenUserInfoEvent(userId)); + const openUserInfo = (userId: number) => DispatchUiEvent(new ModToolsOpenUserInfoEvent(userId)); return ( <> diff --git a/src/components/mod-tools/views/tickets/ModToolsMyIssuesTabView.tsx b/src/components/mod-tools/views/tickets/ModToolsMyIssuesTabView.tsx index bba92740..1c3eb567 100644 --- a/src/components/mod-tools/views/tickets/ModToolsMyIssuesTabView.tsx +++ b/src/components/mod-tools/views/tickets/ModToolsMyIssuesTabView.tsx @@ -1,7 +1,7 @@ import { IssueMessageData, ReleaseIssuesMessageComposer } from '@nitrots/nitro-renderer'; import { FC } from 'react'; +import { SendMessageComposer } from '../../../../api'; import { Base, Button, Column, Grid } from '../../../../common'; -import { SendMessageHook } from '../../../../hooks'; interface ModToolsMyIssuesTabViewProps { @@ -13,7 +13,7 @@ export const ModToolsMyIssuesTabView: FC = props = { const { myIssues = null, onIssueHandleClick = null } = props; - const onReleaseIssue = (issueId: number) => SendMessageHook(new ReleaseIssuesMessageComposer([issueId])); + const onReleaseIssue = (issueId: number) => SendMessageComposer(new ReleaseIssuesMessageComposer([issueId])); return ( diff --git a/src/components/mod-tools/views/tickets/ModToolsOpenIssuesTabView.tsx b/src/components/mod-tools/views/tickets/ModToolsOpenIssuesTabView.tsx index 1d980631..62dc543b 100644 --- a/src/components/mod-tools/views/tickets/ModToolsOpenIssuesTabView.tsx +++ b/src/components/mod-tools/views/tickets/ModToolsOpenIssuesTabView.tsx @@ -1,7 +1,7 @@ import { IssueMessageData, PickIssuesMessageComposer } from '@nitrots/nitro-renderer'; import { FC } from 'react'; +import { SendMessageComposer } from '../../../../api'; import { Base, Button, Column, Grid } from '../../../../common'; -import { SendMessageHook } from '../../../../hooks'; interface ModToolsOpenIssuesTabViewProps { @@ -12,7 +12,7 @@ export const ModToolsOpenIssuesTabView: FC = pro { const { openIssues = null } = props; - const onPickIssue = (issueId: number) => SendMessageHook(new PickIssuesMessageComposer([issueId], false, 0, 'pick issue button')); + const onPickIssue = (issueId: number) => SendMessageComposer(new PickIssuesMessageComposer([issueId], false, 0, 'pick issue button')); return ( diff --git a/src/components/mod-tools/views/user/ModToolsUserChatlogView.tsx b/src/components/mod-tools/views/user/ModToolsUserChatlogView.tsx index 86ba6744..63ec523f 100644 --- a/src/components/mod-tools/views/user/ModToolsUserChatlogView.tsx +++ b/src/components/mod-tools/views/user/ModToolsUserChatlogView.tsx @@ -1,7 +1,8 @@ import { ChatRecordData, GetUserChatlogMessageComposer, UserChatlogEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; +import { SendMessageComposer } from '../../../../api'; import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../common'; -import { BatchUpdates, CreateMessageHook, SendMessageHook } from '../../../../hooks'; +import { BatchUpdates, UseMessageEventHook } from '../../../../hooks'; import { ChatlogView } from '../chatlog/ChatlogView'; interface ModToolsUserChatlogViewProps @@ -29,11 +30,11 @@ export const ModToolsUserChatlogView: FC = props = }); }, [ userId ]); - CreateMessageHook(UserChatlogEvent, onModtoolUserChatlogEvent); + UseMessageEventHook(UserChatlogEvent, onModtoolUserChatlogEvent); useEffect(() => { - SendMessageHook(new GetUserChatlogMessageComposer(userId)); + SendMessageComposer(new GetUserChatlogMessageComposer(userId)); }, [ userId ]); return ( diff --git a/src/components/mod-tools/views/user/ModToolsUserModActionView.tsx b/src/components/mod-tools/views/user/ModToolsUserModActionView.tsx index 785a173e..b5e79b05 100644 --- a/src/components/mod-tools/views/user/ModToolsUserModActionView.tsx +++ b/src/components/mod-tools/views/user/ModToolsUserModActionView.tsx @@ -1,8 +1,7 @@ import { CallForHelpTopicData, DefaultSanctionMessageComposer, ModAlertMessageComposer, ModBanMessageComposer, ModKickMessageComposer, ModMessageMessageComposer, ModMuteMessageComposer, ModTradingLockMessageComposer } from '@nitrots/nitro-renderer'; import { FC, useMemo, useState } from 'react'; -import { LocalizeText } from '../../../../api'; +import { LocalizeText, SendMessageComposer } from '../../../../api'; import { Button, Column, Flex, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../../common'; -import { SendMessageHook } from '../../../../hooks'; import { NotificationAlertType } from '../../../../views/notification-center/common/NotificationAlertType'; import { NotificationUtilities } from '../../../../views/notification-center/common/NotificationUtilities'; import { useModToolsContext } from '../../ModToolsContext'; @@ -61,7 +60,7 @@ export const ModToolsUserModActionView: FC = pro const sendDefaultSanction = () => { - SendMessageHook(new DefaultSanctionMessageComposer(user.userId, selectedTopic, message)); + SendMessageComposer(new DefaultSanctionMessageComposer(user.userId, selectedTopic, message)); onCloseClick(); } @@ -104,11 +103,11 @@ export const ModToolsUserModActionView: FC = pro return; } - SendMessageHook(new ModAlertMessageComposer(user.userId, message, category.id)); + SendMessageComposer(new ModAlertMessageComposer(user.userId, message, category.id)); break; } case ModActionDefinition.MUTE: - SendMessageHook(new ModMuteMessageComposer(user.userId, messageOrDefault, category.id)); + SendMessageComposer(new ModMuteMessageComposer(user.userId, messageOrDefault, category.id)); break; case ModActionDefinition.BAN: { if(!settings.banPermission) @@ -118,7 +117,7 @@ export const ModToolsUserModActionView: FC = pro return; } - SendMessageHook(new ModBanMessageComposer(user.userId, messageOrDefault, category.id, selectedAction, (sanction.actionId === 106))); + SendMessageComposer(new ModBanMessageComposer(user.userId, messageOrDefault, category.id, selectedAction, (sanction.actionId === 106))); break; } case ModActionDefinition.KICK: { @@ -128,13 +127,13 @@ export const ModToolsUserModActionView: FC = pro return; } - SendMessageHook(new ModKickMessageComposer(user.userId, messageOrDefault, category.id)); + SendMessageComposer(new ModKickMessageComposer(user.userId, messageOrDefault, category.id)); break; } case ModActionDefinition.TRADE_LOCK: { const numSeconds = (sanction.actionLengthHours * 60); - SendMessageHook(new ModTradingLockMessageComposer(user.userId, messageOrDefault, numSeconds, category.id)); + SendMessageComposer(new ModTradingLockMessageComposer(user.userId, messageOrDefault, numSeconds, category.id)); break; } case ModActionDefinition.MESSAGE: { @@ -145,7 +144,7 @@ export const ModToolsUserModActionView: FC = pro return; } - SendMessageHook(new ModMessageMessageComposer(user.userId, message, category.id)); + SendMessageComposer(new ModMessageMessageComposer(user.userId, message, category.id)); break; } } diff --git a/src/components/mod-tools/views/user/ModToolsUserRoomVisitsView.tsx b/src/components/mod-tools/views/user/ModToolsUserRoomVisitsView.tsx index e4ba4b79..c0702e50 100644 --- a/src/components/mod-tools/views/user/ModToolsUserRoomVisitsView.tsx +++ b/src/components/mod-tools/views/user/ModToolsUserRoomVisitsView.tsx @@ -1,9 +1,9 @@ import { GetRoomVisitsMessageComposer, RoomVisitsData, RoomVisitsEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; import { AutoSizer, List, ListRowProps } from 'react-virtualized'; -import { TryVisitRoom } from '../../../../api'; +import { SendMessageComposer, TryVisitRoom } from '../../../../api'; import { Base, Column, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../../common'; -import { CreateMessageHook, SendMessageHook } from '../../../../hooks'; +import { UseMessageEventHook } from '../../../../hooks'; interface ModToolsUserRoomVisitsViewProps { @@ -25,7 +25,7 @@ export const ModToolsUserRoomVisitsView: FC = p setRoomVisitData(parser.data); }, [ userId ]); - CreateMessageHook(RoomVisitsEvent, onModtoolReceivedRoomsUserEvent); + UseMessageEventHook(RoomVisitsEvent, onModtoolReceivedRoomsUserEvent); const RowRenderer = (props: ListRowProps) => { @@ -42,7 +42,7 @@ export const ModToolsUserRoomVisitsView: FC = p useEffect(() => { - SendMessageHook(new GetRoomVisitsMessageComposer(userId)); + SendMessageComposer(new GetRoomVisitsMessageComposer(userId)); }, [userId]); if(!userId) return null; diff --git a/src/components/mod-tools/views/user/ModToolsUserSendMessageView.tsx b/src/components/mod-tools/views/user/ModToolsUserSendMessageView.tsx index d081698c..f3e64919 100644 --- a/src/components/mod-tools/views/user/ModToolsUserSendMessageView.tsx +++ b/src/components/mod-tools/views/user/ModToolsUserSendMessageView.tsx @@ -1,8 +1,9 @@ import { ModMessageMessageComposer } from '@nitrots/nitro-renderer'; import { FC, useCallback, useState } from 'react'; +import { SendMessageComposer } from '../../../../api'; import { Button, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../../common'; import { NotificationAlertEvent } from '../../../../events'; -import { dispatchUiEvent, SendMessageHook } from '../../../../hooks'; +import { DispatchUiEvent } from '../../../../hooks'; import { ISelectedUser } from '../../utils/ISelectedUser'; interface ModToolsUserSendMessageViewProps @@ -20,12 +21,12 @@ export const ModToolsUserSendMessageView: FC = { if(message.trim().length === 0) { - dispatchUiEvent(new NotificationAlertEvent([ 'Please write a message to user.' ], null, null, null, 'Error', null)); + DispatchUiEvent(new NotificationAlertEvent([ 'Please write a message to user.' ], null, null, null, 'Error', null)); return; } - SendMessageHook(new ModMessageMessageComposer(user.userId, message, -999)); + SendMessageComposer(new ModMessageMessageComposer(user.userId, message, -999)); onCloseClick(); }, [ message, user, onCloseClick ]); diff --git a/src/components/mod-tools/views/user/ModToolsUserView.tsx b/src/components/mod-tools/views/user/ModToolsUserView.tsx index 33ac06d6..6594e476 100644 --- a/src/components/mod-tools/views/user/ModToolsUserView.tsx +++ b/src/components/mod-tools/views/user/ModToolsUserView.tsx @@ -1,9 +1,9 @@ import { FriendlyTime, GetModeratorUserInfoMessageComposer, ModeratorUserInfoData, ModeratorUserInfoEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useMemo, useState } from 'react'; -import { LocalizeText } from '../../../../api'; +import { LocalizeText, SendMessageComposer } from '../../../../api'; import { Button, Column, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../common'; -import { ModToolsOpenUserChatlogEvent } from '../../../../events/mod-tools/ModToolsOpenUserChatlogEvent'; -import { CreateMessageHook, dispatchUiEvent, SendMessageHook } from '../../../../hooks'; +import { ModToolsOpenUserChatlogEvent } from '../../../../events'; +import { DispatchUiEvent, UseMessageEventHook } from '../../../../hooks'; import { ModToolsUserModActionView } from './ModToolsUserModActionView'; import { ModToolsUserRoomVisitsView } from './ModToolsUserRoomVisitsView'; import { ModToolsUserSendMessageView } from './ModToolsUserSendMessageView'; @@ -31,7 +31,7 @@ export const ModToolsUserView: FC = props => setUserInfo(parser.data); }, [ userId ]); - CreateMessageHook(ModeratorUserInfoEvent, onModtoolUserInfoEvent); + UseMessageEventHook(ModeratorUserInfoEvent, onModtoolUserInfoEvent); const userProperties = useMemo(() => { @@ -100,7 +100,7 @@ export const ModToolsUserView: FC = props => useEffect(() => { - SendMessageHook(new GetModeratorUserInfoMessageComposer(userId)); + SendMessageComposer(new GetModeratorUserInfoMessageComposer(userId)); }, [ userId ]); if(!userInfo) return null; @@ -132,7 +132,7 @@ export const ModToolsUserView: FC = props => - - - - + + + + + ); } diff --git a/src/components/navigator/views/room-settings/views/NavigatorRoomSettingsRightsTabView.tsx b/src/components/navigator/views/room-settings/views/NavigatorRoomSettingsRightsTabView.tsx index 01d68153..902ae41d 100644 --- a/src/components/navigator/views/room-settings/views/NavigatorRoomSettingsRightsTabView.tsx +++ b/src/components/navigator/views/room-settings/views/NavigatorRoomSettingsRightsTabView.tsx @@ -1,13 +1,7 @@ import { RemoveAllRightsMessageComposer, RoomTakeRightsComposer } from '@nitrots/nitro-renderer'; import { FC, useCallback } from 'react'; -import { LocalizeText } from '../../../../../api'; -import { UserProfileIconView } from '../../../../../common'; -import { Button } from '../../../../../common/Button'; -import { Column } from '../../../../../common/Column'; -import { Flex } from '../../../../../common/Flex'; -import { Grid } from '../../../../../common/Grid'; -import { Text } from '../../../../../common/Text'; -import { SendMessageHook } from '../../../../../hooks'; +import { LocalizeText, SendMessageComposer } from '../../../../../api'; +import { Button, Column, Flex, Grid, Text, UserProfileIconView } from '../../../../../common'; import { NavigatorRoomSettingsTabViewProps } from './NavigatorRoomSettingsTabViewProps.types'; export const NavigatorRoomSettingsRightsTabView: FC = props => @@ -18,66 +12,64 @@ export const NavigatorRoomSettingsRightsTabView: FC { handleChange('remove_all_rights', null); - SendMessageHook(new RemoveAllRightsMessageComposer(roomSettingsData.roomId)); + SendMessageComposer(new RemoveAllRightsMessageComposer(roomSettingsData.roomId)); }, [ roomSettingsData, handleChange ]); return ( - <> - - - - { LocalizeText('navigator.flatctrls.userswithrights', [ 'displayed', 'total' ], [ roomSettingsData.usersWithRights.size.toString(), roomSettingsData.usersWithRights.size.toString() ]) } - - - { Array.from(roomSettingsData.usersWithRights.entries()).map(([id, name], index) => - { - return ( - - - removeUserRights(id) }> { name } - - ); - }) } - - + + + + { LocalizeText('navigator.flatctrls.userswithrights', [ 'displayed', 'total' ], [ roomSettingsData.usersWithRights.size.toString(), roomSettingsData.usersWithRights.size.toString() ]) } + + + { Array.from(roomSettingsData.usersWithRights.entries()).map(([id, name], index) => + { + return ( + + + removeUserRights(id) }> { name } + + ); + }) } - - - { LocalizeText('navigator.roomsettings.moderation.mute.header') } - - handleChange('moderation_mute', (event.target.checked ? 1 : 0)) } /> - { LocalizeText('navigator.roomsettings.moderation.rights') } - - - - {LocalizeText('navigator.roomsettings.moderation.kick.header')} - - handleChange('moderation_kick', (event.target.checked ? 0 : 2)) } /> - { LocalizeText('navigator.roomsettings.moderation.all') } - - - handleChange('moderation_kick', (event.target.checked ? 1 : 2)) } /> - { LocalizeText('navigator.roomsettings.moderation.rights') } - - - - {LocalizeText('navigator.roomsettings.moderation.ban.header')} - - handleChange('moderation_ban', (event.target.checked ? 1 : 0)) } /> - { LocalizeText('navigator.roomsettings.moderation.rights') } - - + + + + + { LocalizeText('navigator.roomsettings.moderation.mute.header') } + + handleChange('moderation_mute', (event.target.checked ? 1 : 0)) } /> + { LocalizeText('navigator.roomsettings.moderation.rights') } + - - + + {LocalizeText('navigator.roomsettings.moderation.kick.header')} + + handleChange('moderation_kick', (event.target.checked ? 0 : 2)) } /> + { LocalizeText('navigator.roomsettings.moderation.all') } + + + handleChange('moderation_kick', (event.target.checked ? 1 : 2)) } /> + { LocalizeText('navigator.roomsettings.moderation.rights') } + + + + {LocalizeText('navigator.roomsettings.moderation.ban.header')} + + handleChange('moderation_ban', (event.target.checked ? 1 : 0)) } /> + { LocalizeText('navigator.roomsettings.moderation.rights') } + + + + ); } diff --git a/src/components/navigator/views/search-result/NavigatorSearchResultItemView.tsx b/src/components/navigator/views/search-result/NavigatorSearchResultItemView.tsx index 124ddfe9..f4b55215 100644 --- a/src/components/navigator/views/search-result/NavigatorSearchResultItemView.tsx +++ b/src/components/navigator/views/search-result/NavigatorSearchResultItemView.tsx @@ -2,11 +2,9 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { RoomDataParser } from '@nitrots/nitro-renderer'; import { FC, MouseEvent } from 'react'; import { CreateRoomSession, GetSessionDataManager, TryVisitRoom } from '../../../../api'; -import { Flex } from '../../../../common/Flex'; -import { LayoutGridItemProps } from '../../../../common/layout/LayoutGridItem'; -import { Text } from '../../../../common/Text'; +import { Flex, LayoutGridItemProps, Text } from '../../../../common'; import { UpdateDoorStateEvent } from '../../../../events'; -import { dispatchUiEvent } from '../../../../hooks'; +import { DispatchUiEvent } from '../../../../hooks'; export interface NavigatorSearchResultItemViewProps extends LayoutGridItemProps { @@ -59,10 +57,10 @@ export const NavigatorSearchResultItemView: FC = props => }); }, []); - CreateMessageHook(UserCreditsEvent, onUserCreditsEvent); + UseMessageEventHook(UserCreditsEvent, onUserCreditsEvent); const onUserCurrencyEvent = useCallback((event: UserCurrencyEvent) => { @@ -101,7 +98,7 @@ export const PurseView: FC<{}> = props => }); }, []); - CreateMessageHook(UserCurrencyEvent, onUserCurrencyEvent); + UseMessageEventHook(UserCurrencyEvent, onUserCurrencyEvent); const onActivityPointNotificationMessageEvent = useCallback((event: ActivityPointNotificationMessageEvent) => { @@ -121,7 +118,7 @@ export const PurseView: FC<{}> = props => }); }, []); - CreateMessageHook(ActivityPointNotificationMessageEvent, onActivityPointNotificationMessageEvent); + UseMessageEventHook(ActivityPointNotificationMessageEvent, onActivityPointNotificationMessageEvent); const onUserSubscriptionEvent = useCallback((event: UserSubscriptionEvent) => { @@ -147,7 +144,7 @@ export const PurseView: FC<{}> = props => }); }, []); - CreateMessageHook(UserSubscriptionEvent, onUserSubscriptionEvent); + UseMessageEventHook(UserSubscriptionEvent, onUserSubscriptionEvent); useEffect(() => { @@ -156,16 +153,16 @@ export const PurseView: FC<{}> = props => useEffect(() => { - SendMessageHook(new UserSubscriptionComposer('habbo_club')); + SendMessageComposer(new UserSubscriptionComposer('habbo_club')); - const interval = setInterval(() => SendMessageHook(new UserSubscriptionComposer('habbo_club')), 50000); + const interval = setInterval(() => SendMessageComposer(new UserSubscriptionComposer('habbo_club')), 50000); return () => clearInterval(interval); }, [ purse ]); useEffect(() => { - SendMessageHook(new UserCurrencyComposer()); + SendMessageComposer(new UserCurrencyComposer()); }, []); if(!purse) return null; @@ -179,7 +176,7 @@ export const PurseView: FC<{}> = props => { getCurrencyElements(0, 2) } - dispatchUiEvent(new HcCenterEvent(HcCenterEvent.TOGGLE_HC_CENTER)) }> + DispatchUiEvent(new HcCenterEvent(HcCenterEvent.TOGGLE_HC_CENTER)) }> { getClubText } @@ -187,7 +184,7 @@ export const PurseView: FC<{}> = props => CreateLinkEvent('help/show') }> - dispatchUiEvent(new UserSettingsUIEvent(UserSettingsUIEvent.TOGGLE_USER_SETTINGS)) } > + DispatchUiEvent(new UserSettingsUIEvent(UserSettingsUIEvent.TOGGLE_USER_SETTINGS)) } > diff --git a/src/components/room-host/RoomHostView.tsx b/src/components/room-host/RoomHostView.tsx index 4edcfe95..73749a44 100644 --- a/src/components/room-host/RoomHostView.tsx +++ b/src/components/room-host/RoomHostView.tsx @@ -2,8 +2,7 @@ import { IRoomSession, RoomEngineEvent, RoomId, RoomSessionEvent } from '@nitrot import { FC, useCallback, useState } from 'react'; import { GetRoomSession, SetActiveRoomId, StartRoomSession } from '../../api'; import { Base, TransitionAnimation, TransitionAnimationTypes } from '../../common'; -import { useRoomEngineEvent } from '../../hooks/events/nitro/room/room-engine-event'; -import { useRoomSessionManagerEvent } from '../../hooks/events/nitro/session/room-session-manager-event'; +import { UseRoomEngineEvent, UseRoomSessionManagerEvent } from '../../hooks'; import { RoomView } from '../../views/room/RoomView'; export const RoomHostView: FC<{}> = props => @@ -30,8 +29,8 @@ export const RoomHostView: FC<{}> = props => } }, []); - useRoomEngineEvent(RoomEngineEvent.INITIALIZED, onRoomEngineEvent); - useRoomEngineEvent(RoomEngineEvent.DISPOSED, onRoomEngineEvent); + UseRoomEngineEvent(RoomEngineEvent.INITIALIZED, onRoomEngineEvent); + UseRoomEngineEvent(RoomEngineEvent.DISPOSED, onRoomEngineEvent); const onRoomSessionEvent = useCallback((event: RoomSessionEvent) => { @@ -46,8 +45,8 @@ export const RoomHostView: FC<{}> = props => } }, []); - useRoomSessionManagerEvent(RoomSessionEvent.CREATED, onRoomSessionEvent); - useRoomSessionManagerEvent(RoomSessionEvent.ENDED, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionEvent.CREATED, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionEvent.ENDED, onRoomSessionEvent); return ( diff --git a/src/components/toolbar/ToolbarView.tsx b/src/components/toolbar/ToolbarView.tsx index 5f9200c3..5b01310f 100644 --- a/src/components/toolbar/ToolbarView.tsx +++ b/src/components/toolbar/ToolbarView.tsx @@ -1,15 +1,9 @@ import { Dispose, DropBounce, EaseOut, FigureUpdateEvent, JumpBy, Motions, NitroToolbarAnimateIconEvent, PerkAllowancesMessageEvent, PerkEnum, Queue, UserInfoDataParser, UserInfoEvent, Wait } from '@nitrots/nitro-renderer'; import { FC, useCallback, useState } from 'react'; import { CreateLinkEvent, GetRoomSession, GetRoomSessionManager, GetSessionDataManager, GetUserProfile, GoToDesktop, OpenMessengerChat } from '../../api'; -import { Base, Flex, TransitionAnimationTypes } from '../../common'; -import { TransitionAnimation } from '../../common/transitions/TransitionAnimation'; -import { FriendsEvent, FriendsMessengerIconEvent, FriendsRequestCountEvent, GuideToolEvent, InventoryEvent, NavigatorEvent } from '../../events'; -import { AchievementsUIEvent, AchievementsUIUnseenCountEvent } from '../../events/achievements'; -import { UnseenItemTrackerUpdateEvent } from '../../events/inventory/UnseenItemTrackerUpdateEvent'; -import { ModToolsEvent } from '../../events/mod-tools/ModToolsEvent'; -import { UserSettingsUIEvent } from '../../events/user-settings/UserSettingsUIEvent'; -import { BatchUpdates, dispatchUiEvent, useRoomEngineEvent, useUiEvent } from '../../hooks'; -import { CreateMessageHook } from '../../hooks/messages/message-event'; +import { Base, Flex, TransitionAnimation, TransitionAnimationTypes } from '../../common'; +import { AchievementsUIEvent, AchievementsUIUnseenCountEvent, FriendsEvent, FriendsMessengerIconEvent, FriendsRequestCountEvent, GuideToolEvent, InventoryEvent, ModToolsEvent, NavigatorEvent, UnseenItemTrackerUpdateEvent, UserSettingsUIEvent } from '../../events'; +import { BatchUpdates, DispatchUiEvent, UseMessageEventHook, UseRoomEngineEvent, UseUiEvent } from '../../hooks'; import { AvatarImageView } from '../../views/shared/avatar-image/AvatarImageView'; import { ItemCountView } from '../../views/shared/item-count/ItemCountView'; import { ToolbarViewItems } from './common/ToolbarViewItems'; @@ -49,7 +43,7 @@ export const ToolbarView: FC = props => }); }, []); - CreateMessageHook(UserInfoEvent, onUserInfoEvent); + UseMessageEventHook(UserInfoEvent, onUserInfoEvent); const onUserFigureEvent = useCallback((event: FigureUpdateEvent) => { @@ -58,7 +52,7 @@ export const ToolbarView: FC = props => setUserFigure(parser.figure); }, []); - CreateMessageHook(FigureUpdateEvent, onUserFigureEvent); + UseMessageEventHook(FigureUpdateEvent, onUserFigureEvent); const onPerkAllowancesMessageEvent = useCallback((event: PerkAllowancesMessageEvent) => { @@ -67,35 +61,35 @@ export const ToolbarView: FC = props => setUseGuideTool(parser.isAllowed(PerkEnum.USE_GUIDE_TOOL)); }, [ setUseGuideTool ]); - CreateMessageHook(PerkAllowancesMessageEvent, onPerkAllowancesMessageEvent); + UseMessageEventHook(PerkAllowancesMessageEvent, onPerkAllowancesMessageEvent); const onFriendsMessengerIconEvent = useCallback((event: FriendsMessengerIconEvent) => { setChatIconType(event.iconType); }, []); - useUiEvent(FriendsMessengerIconEvent.UPDATE_ICON, onFriendsMessengerIconEvent); + UseUiEvent(FriendsMessengerIconEvent.UPDATE_ICON, onFriendsMessengerIconEvent); const onUnseenItemTrackerUpdateEvent = useCallback((event: UnseenItemTrackerUpdateEvent) => { setUnseenInventoryCount(event.count); }, []); - useUiEvent(UnseenItemTrackerUpdateEvent.UPDATE_COUNT, onUnseenItemTrackerUpdateEvent); + UseUiEvent(UnseenItemTrackerUpdateEvent.UPDATE_COUNT, onUnseenItemTrackerUpdateEvent); const onAchievementsUIUnseenCountEvent = useCallback((event: AchievementsUIUnseenCountEvent) => { setUnseenAchievementCount(event.count); }, []); - useUiEvent(AchievementsUIUnseenCountEvent.UNSEEN_COUNT, onAchievementsUIUnseenCountEvent); + UseUiEvent(AchievementsUIUnseenCountEvent.UNSEEN_COUNT, onAchievementsUIUnseenCountEvent); const onFriendsRequestCountEvent = useCallback((event: FriendsRequestCountEvent) => { setFriendRequestCount(event.count); }, []); - useUiEvent(FriendsRequestCountEvent.UPDATE_COUNT, onFriendsRequestCountEvent); + UseUiEvent(FriendsRequestCountEvent.UPDATE_COUNT, onFriendsRequestCountEvent); const animationIconToToolbar = useCallback((iconName: string, image: HTMLImageElement, x: number, y: number) => { @@ -136,23 +130,23 @@ export const ToolbarView: FC = props => animationIconToToolbar('icon-inventory', event.image, event.x, event.y); }, [ animationIconToToolbar ]); - useRoomEngineEvent(NitroToolbarAnimateIconEvent.ANIMATE_ICON, onNitroToolbarAnimateIconEvent); + UseRoomEngineEvent(NitroToolbarAnimateIconEvent.ANIMATE_ICON, onNitroToolbarAnimateIconEvent); const handleToolbarItemClick = useCallback((item: string) => { switch(item) { case ToolbarViewItems.NAVIGATOR_ITEM: - dispatchUiEvent(new NavigatorEvent(NavigatorEvent.TOGGLE_NAVIGATOR)); + DispatchUiEvent(new NavigatorEvent(NavigatorEvent.TOGGLE_NAVIGATOR)); return; case ToolbarViewItems.INVENTORY_ITEM: - dispatchUiEvent(new InventoryEvent(InventoryEvent.TOGGLE_INVENTORY)); + DispatchUiEvent(new InventoryEvent(InventoryEvent.TOGGLE_INVENTORY)); return; case ToolbarViewItems.CATALOG_ITEM: CreateLinkEvent('catalog/toggle'); return; case ToolbarViewItems.FRIEND_LIST_ITEM: - dispatchUiEvent(new FriendsEvent(FriendsEvent.TOGGLE_FRIEND_LIST)); + DispatchUiEvent(new FriendsEvent(FriendsEvent.TOGGLE_FRIEND_LIST)); return; case ToolbarViewItems.CAMERA_ITEM: CreateLinkEvent('camera/toggle'); @@ -162,10 +156,10 @@ export const ToolbarView: FC = props => setMeExpanded(false); return; case ToolbarViewItems.MOD_TOOLS_ITEM: - dispatchUiEvent(new ModToolsEvent(ModToolsEvent.TOGGLE_MOD_TOOLS)); + DispatchUiEvent(new ModToolsEvent(ModToolsEvent.TOGGLE_MOD_TOOLS)); return; case ToolbarViewItems.ACHIEVEMENTS_ITEM: - dispatchUiEvent(new AchievementsUIEvent(AchievementsUIEvent.TOGGLE_ACHIEVEMENTS)); + DispatchUiEvent(new AchievementsUIEvent(AchievementsUIEvent.TOGGLE_ACHIEVEMENTS)); setMeExpanded(false); return; case ToolbarViewItems.PROFILE_ITEM: @@ -173,11 +167,11 @@ export const ToolbarView: FC = props => setMeExpanded(false); return; case ToolbarViewItems.SETTINGS_ITEM: - dispatchUiEvent(new UserSettingsUIEvent(UserSettingsUIEvent.TOGGLE_USER_SETTINGS)); + DispatchUiEvent(new UserSettingsUIEvent(UserSettingsUIEvent.TOGGLE_USER_SETTINGS)); setMeExpanded(false); return; case ToolbarViewItems.GUIDE_TOOL_ITEM: - dispatchUiEvent(new GuideToolEvent(GuideToolEvent.TOGGLE_GUIDE_TOOL)); + DispatchUiEvent(new GuideToolEvent(GuideToolEvent.TOGGLE_GUIDE_TOOL)); setMeExpanded(false); return; case ToolbarViewItems.FRIEND_CHAT_ITEM: diff --git a/src/components/user-profile/UserProfileView.tsx b/src/components/user-profile/UserProfileView.tsx index 52b13e49..7dadef27 100644 --- a/src/components/user-profile/UserProfileView.tsx +++ b/src/components/user-profile/UserProfileView.tsx @@ -1,8 +1,8 @@ import { RelationshipStatusInfoEvent, RelationshipStatusInfoMessageParser, UserCurrentBadgesComposer, UserCurrentBadgesEvent, UserProfileEvent, UserProfileParser, UserRelationshipsComposer } from '@nitrots/nitro-renderer'; import { FC, useCallback, useState } from 'react'; -import { GetSessionDataManager, GetUserProfile, LocalizeText } from '../../api'; +import { GetSessionDataManager, GetUserProfile, LocalizeText, SendMessageComposer } from '../../api'; import { Column, Flex, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../common'; -import { BatchUpdates, CreateMessageHook, SendMessageHook } from '../../hooks'; +import { BatchUpdates, UseMessageEventHook } from '../../hooks'; import { BadgesContainerView } from './views/BadgesContainerView'; import { FriendsContainerView } from './views/FriendsContainerView'; import { GroupsContainerView } from './views/GroupsContainerView'; @@ -41,7 +41,7 @@ export const UserProfileView: FC<{}> = props => setUserBadges(parser.badges); }, [ userProfile ]); - CreateMessageHook(UserCurrentBadgesEvent, onUserCurrentBadgesEvent); + UseMessageEventHook(UserCurrentBadgesEvent, onUserCurrentBadgesEvent); const OnUserRelationshipsEvent = useCallback((event: RelationshipStatusInfoEvent) => { @@ -52,7 +52,7 @@ export const UserProfileView: FC<{}> = props => setUserRelationships(parser); }, [ userProfile ]); - CreateMessageHook(RelationshipStatusInfoEvent, OnUserRelationshipsEvent); + UseMessageEventHook(RelationshipStatusInfoEvent, OnUserRelationshipsEvent); const onUserProfileEvent = useCallback((event: UserProfileEvent) => { @@ -70,11 +70,11 @@ export const UserProfileView: FC<{}> = props => setUserProfile(parser); - SendMessageHook(new UserCurrentBadgesComposer(parser.id)); - SendMessageHook(new UserRelationshipsComposer(parser.id)); + SendMessageComposer(new UserCurrentBadgesComposer(parser.id)); + SendMessageComposer(new UserRelationshipsComposer(parser.id)); }, [ userProfile ]); - CreateMessageHook(UserProfileEvent, onUserProfileEvent); + UseMessageEventHook(UserProfileEvent, onUserProfileEvent); if(!userProfile) return null; diff --git a/src/components/user-profile/views/GroupsContainerView.tsx b/src/components/user-profile/views/GroupsContainerView.tsx index dc592430..ffde4cd1 100644 --- a/src/components/user-profile/views/GroupsContainerView.tsx +++ b/src/components/user-profile/views/GroupsContainerView.tsx @@ -1,7 +1,8 @@ import { GroupFavoriteComposer, GroupInformationComposer, GroupInformationEvent, GroupInformationParser, HabboGroupEntryData } from '@nitrots/nitro-renderer'; import classNames from 'classnames'; import { FC, useCallback, useEffect, useState } from 'react'; -import { CreateMessageHook, SendMessageHook } from '../../../hooks'; +import { SendMessageComposer } from '../../../api'; +import { UseMessageEventHook } from '../../../hooks'; import { BadgeImageView } from '../../../views/shared/badge-image/BadgeImageView'; import { GroupInformationView } from '../../groups/views/GroupInformationView'; @@ -30,7 +31,7 @@ export const GroupsContainerView: FC = props => setGroupInformation(parser); }, [ groupInformation, selectedGroupId ]); - CreateMessageHook(GroupInformationEvent, onGroupInformationEvent); + UseMessageEventHook(GroupInformationEvent, onGroupInformationEvent); useEffect(() => { @@ -39,12 +40,12 @@ export const GroupsContainerView: FC = props => useEffect(() => { - if(selectedGroupId) SendMessageHook(new GroupInformationComposer(selectedGroupId, false)); + if(selectedGroupId) SendMessageComposer(new GroupInformationComposer(selectedGroupId, false)); }, [ selectedGroupId ]); const favoriteGroup = useCallback((groupId: number) => { - SendMessageHook(new GroupFavoriteComposer(groupId)); + SendMessageComposer(new GroupFavoriteComposer(groupId)); }, []); if(!groups) return null; diff --git a/src/components/user-settings/UserSettingsView.tsx b/src/components/user-settings/UserSettingsView.tsx index 6dbe3361..298b482e 100644 --- a/src/components/user-settings/UserSettingsView.tsx +++ b/src/components/user-settings/UserSettingsView.tsx @@ -1,10 +1,10 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { NitroSettingsEvent, UserSettingsCameraFollowComposer, UserSettingsEvent, UserSettingsOldChatComposer, UserSettingsRoomInvitesComposer, UserSettingsSoundComposer } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; -import { LocalizeText } from '../../api'; +import { LocalizeText, SendMessageComposer } from '../../api'; import { Column, Flex, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../common'; -import { UserSettingsUIEvent } from '../../events/user-settings/UserSettingsUIEvent'; -import { CreateMessageHook, dispatchMainEvent, SendMessageHook, useUiEvent } from '../../hooks'; +import { UserSettingsUIEvent } from '../../events'; +import { DispatchUiEvent, UseMessageEventHook, UseUiEvent } from '../../hooks'; export const UserSettingsView: FC<{}> = props => { @@ -27,9 +27,9 @@ export const UserSettingsView: FC<{}> = props => } }, []); - useUiEvent(UserSettingsUIEvent.SHOW_USER_SETTINGS, onUserSettingsUIEvent); - useUiEvent(UserSettingsUIEvent.HIDE_USER_SETTINGS, onUserSettingsUIEvent); - useUiEvent(UserSettingsUIEvent.TOGGLE_USER_SETTINGS, onUserSettingsUIEvent); + UseUiEvent(UserSettingsUIEvent.SHOW_USER_SETTINGS, onUserSettingsUIEvent); + UseUiEvent(UserSettingsUIEvent.HIDE_USER_SETTINGS, onUserSettingsUIEvent); + UseUiEvent(UserSettingsUIEvent.TOGGLE_USER_SETTINGS, onUserSettingsUIEvent); const onUserSettingsEvent = useCallback((event: UserSettingsEvent) => { @@ -48,7 +48,7 @@ export const UserSettingsView: FC<{}> = props => setUserSettings(settingsEvent); }, []); - CreateMessageHook(UserSettingsEvent, onUserSettingsEvent); + UseMessageEventHook(UserSettingsEvent, onUserSettingsEvent); const processAction = useCallback((type: string, value?: boolean | number | string) => { @@ -64,15 +64,15 @@ export const UserSettingsView: FC<{}> = props => return; case 'oldchat': clone.oldChat = value as boolean; - SendMessageHook(new UserSettingsOldChatComposer(clone.oldChat)); + SendMessageComposer(new UserSettingsOldChatComposer(clone.oldChat)); break; case 'room_invites': clone.roomInvites = value as boolean; - SendMessageHook(new UserSettingsRoomInvitesComposer(clone.roomInvites)); + SendMessageComposer(new UserSettingsRoomInvitesComposer(clone.roomInvites)); break; case 'camera_follow': clone.cameraFollow = value as boolean; - SendMessageHook(new UserSettingsCameraFollowComposer(clone.cameraFollow)); + SendMessageComposer(new UserSettingsCameraFollowComposer(clone.cameraFollow)); break; case 'system_volume': clone.volumeSystem = value as number; @@ -99,7 +99,7 @@ export const UserSettingsView: FC<{}> = props => switch(type) { case 'volume': - SendMessageHook(new UserSettingsSoundComposer(Math.round(userSettings.volumeSystem), Math.round(userSettings.volumeFurni), Math.round(userSettings.volumeTrax))); + SendMessageComposer(new UserSettingsSoundComposer(Math.round(userSettings.volumeSystem), Math.round(userSettings.volumeFurni), Math.round(userSettings.volumeTrax))); break; } }, [userSettings]); @@ -108,7 +108,7 @@ export const UserSettingsView: FC<{}> = props => { if(!userSettings) return; - dispatchMainEvent(userSettings); + DispatchUiEvent(userSettings); }, [userSettings]); if(!isVisible) return null; diff --git a/src/components/wired/WiredMessageHandler.tsx b/src/components/wired/WiredMessageHandler.tsx index c2887290..0819f9b1 100644 --- a/src/components/wired/WiredMessageHandler.tsx +++ b/src/components/wired/WiredMessageHandler.tsx @@ -1,6 +1,6 @@ import { WiredFurniActionEvent, WiredFurniConditionEvent, WiredFurniTriggerEvent, WiredOpenEvent, WiredRewardResultMessageEvent, WiredSaveSuccessEvent, WiredValidationErrorEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback } from 'react'; -import { CreateMessageHook } from '../../hooks/messages'; +import { UseMessageEventHook } from '../../hooks/messages'; import { useWiredContext } from './context/WiredContext'; export const WiredMessageHandler: FC<{}> = props => @@ -54,13 +54,13 @@ export const WiredMessageHandler: FC<{}> = props => console.log(parser); }, []); - CreateMessageHook(WiredFurniActionEvent, onWiredFurniActionEvent); - CreateMessageHook(WiredFurniConditionEvent, onWiredFurniConditionEvent); - CreateMessageHook(WiredFurniTriggerEvent, onWiredFurniTriggerEvent); - CreateMessageHook(WiredOpenEvent, onWiredOpenEvent); - CreateMessageHook(WiredRewardResultMessageEvent, onWiredRewardResultMessageEvent); - CreateMessageHook(WiredSaveSuccessEvent, onWiredSaveSuccessEvent); - CreateMessageHook(WiredValidationErrorEvent, onWiredValidationErrorEvent); + UseMessageEventHook(WiredFurniActionEvent, onWiredFurniActionEvent); + UseMessageEventHook(WiredFurniConditionEvent, onWiredFurniConditionEvent); + UseMessageEventHook(WiredFurniTriggerEvent, onWiredFurniTriggerEvent); + UseMessageEventHook(WiredOpenEvent, onWiredOpenEvent); + UseMessageEventHook(WiredRewardResultMessageEvent, onWiredRewardResultMessageEvent); + UseMessageEventHook(WiredSaveSuccessEvent, onWiredSaveSuccessEvent); + UseMessageEventHook(WiredValidationErrorEvent, onWiredValidationErrorEvent); return null; }; diff --git a/src/components/wired/WiredView.tsx b/src/components/wired/WiredView.tsx index 51bad7c7..97bc67c6 100644 --- a/src/components/wired/WiredView.tsx +++ b/src/components/wired/WiredView.tsx @@ -1,9 +1,8 @@ import { ConditionDefinition, Triggerable, TriggerDefinition, UpdateActionMessageComposer, UpdateConditionMessageComposer, UpdateTriggerMessageComposer, WiredActionDefinition } from '@nitrots/nitro-renderer'; import { FC, useCallback, useMemo, useState } from 'react'; -import { IsOwnerOfFloorFurniture } from '../../api'; +import { IsOwnerOfFloorFurniture, SendMessageComposer } from '../../api'; import { WiredEvent } from '../../events'; -import { useUiEvent } from '../../hooks/events'; -import { SendMessageHook } from '../../hooks/messages'; +import { UseUiEvent } from '../../hooks'; import { GetWiredLayout } from './common/GetWiredLayout'; import { WiredContextProvider } from './context/WiredContext'; import { WiredMessageHandler } from './WiredMessageHandler'; @@ -30,21 +29,21 @@ export const WiredView: FC<{}> = props => if(trigger instanceof WiredActionDefinition) { - SendMessageHook(new UpdateActionMessageComposer(trigger.id, intParams, stringParam, furniIds, actionDelay, trigger.stuffTypeSelectionCode)); + SendMessageComposer(new UpdateActionMessageComposer(trigger.id, intParams, stringParam, furniIds, actionDelay, trigger.stuffTypeSelectionCode)); } else if(trigger instanceof TriggerDefinition) { - SendMessageHook(new UpdateTriggerMessageComposer(trigger.id, intParams, stringParam, furniIds, trigger.stuffTypeSelectionCode)); + SendMessageComposer(new UpdateTriggerMessageComposer(trigger.id, intParams, stringParam, furniIds, trigger.stuffTypeSelectionCode)); } else if(trigger instanceof ConditionDefinition) { - SendMessageHook(new UpdateConditionMessageComposer(trigger.id, intParams, stringParam, furniIds, trigger.stuffTypeSelectionCode)); + SendMessageComposer(new UpdateConditionMessageComposer(trigger.id, intParams, stringParam, furniIds, trigger.stuffTypeSelectionCode)); } }, [ trigger, intParams, stringParam, furniIds, actionDelay ]); - useUiEvent(WiredEvent.SAVE_WIRED, onWiredEvent); + UseUiEvent(WiredEvent.SAVE_WIRED, onWiredEvent); return ( diff --git a/src/components/wired/views/WiredBaseView.tsx b/src/components/wired/views/WiredBaseView.tsx index 757270a0..255920bf 100644 --- a/src/components/wired/views/WiredBaseView.tsx +++ b/src/components/wired/views/WiredBaseView.tsx @@ -1,13 +1,8 @@ import { FC, useCallback, useEffect, useState } from 'react'; import { GetSessionDataManager, LocalizeText } from '../../../api'; -import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../common'; -import { Button } from '../../../common/Button'; -import { Column } from '../../../common/Column'; -import { Flex } from '../../../common/Flex'; -import { Text } from '../../../common/Text'; +import { Button, Column, Flex, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../common'; import { WiredEvent } from '../../../events'; -import { BatchUpdates } from '../../../hooks'; -import { dispatchUiEvent } from '../../../hooks/events'; +import { BatchUpdates, DispatchUiEvent } from '../../../hooks'; import { WiredFurniType } from '../common/WiredFurniType'; import { WiredSelectionVisualizer } from '../common/WiredSelectionVisualizer'; import { useWiredContext } from '../context/WiredContext'; @@ -34,7 +29,7 @@ export const WiredBaseView: FC = props => if(save) save(); - setTimeout(() => dispatchUiEvent(new WiredEvent(WiredEvent.SAVE_WIRED)), 1); + setTimeout(() => DispatchUiEvent(new WiredEvent(WiredEvent.SAVE_WIRED)), 1); }, [ save, validate ]); const close = useCallback(() => diff --git a/src/components/wired/views/WiredFurniSelectorView.tsx b/src/components/wired/views/WiredFurniSelectorView.tsx index 2bda2a08..616261a2 100644 --- a/src/components/wired/views/WiredFurniSelectorView.tsx +++ b/src/components/wired/views/WiredFurniSelectorView.tsx @@ -1,9 +1,8 @@ import { FC, useCallback, useEffect } from 'react'; import { LocalizeText } from '../../../api'; -import { Column } from '../../../common/Column'; -import { Text } from '../../../common/Text'; +import { Column, Text } from '../../../common'; import { WiredSelectObjectEvent } from '../../../events'; -import { useUiEvent } from '../../../hooks/events'; +import { UseUiEvent } from '../../../hooks'; import { WiredSelectionVisualizer } from '../common/WiredSelectionVisualizer'; import { useWiredContext } from '../context/WiredContext'; @@ -45,7 +44,7 @@ export const WiredFurniSelectorView: FC<{}> = props => }); }, [ trigger, setFurniIds ]); - useUiEvent(WiredSelectObjectEvent.SELECT_OBJECT, onWiredSelectObjectEvent); + UseUiEvent(WiredSelectObjectEvent.SELECT_OBJECT, onWiredSelectObjectEvent); useEffect(() => { diff --git a/src/hooks/events/DispatchEventHook.ts b/src/hooks/events/DispatchEventHook.ts new file mode 100644 index 00000000..97d291fc --- /dev/null +++ b/src/hooks/events/DispatchEventHook.ts @@ -0,0 +1,3 @@ +import { IEventDispatcher, NitroEvent } from '@nitrots/nitro-renderer'; + +export const DispatchEventHook = (eventDispatcher: IEventDispatcher, event: NitroEvent) => eventDispatcher.dispatchEvent(event); diff --git a/src/hooks/events/UseEventDispatcherHook.tsx b/src/hooks/events/UseEventDispatcherHook.tsx new file mode 100644 index 00000000..36664c1c --- /dev/null +++ b/src/hooks/events/UseEventDispatcherHook.tsx @@ -0,0 +1,12 @@ +import { IEventDispatcher, NitroEvent } from '@nitrots/nitro-renderer'; +import { useEffect } from 'react'; + +export const UseEventDispatcherHook = (type: string, eventDispatcher: IEventDispatcher, handler: (event: NitroEvent) => void) => +{ + useEffect(() => + { + eventDispatcher.addEventListener(type, handler); + + return () => eventDispatcher.removeEventListener(type, handler); + }, [ type, eventDispatcher, handler ]); +} diff --git a/src/hooks/events/core/UseCommunicationEvent.tsx b/src/hooks/events/core/UseCommunicationEvent.tsx new file mode 100644 index 00000000..ee196afb --- /dev/null +++ b/src/hooks/events/core/UseCommunicationEvent.tsx @@ -0,0 +1,5 @@ +import { NitroEvent } from '@nitrots/nitro-renderer'; +import { GetCommunication } from '../../../api'; +import { UseEventDispatcherHook } from '../UseEventDispatcherHook'; + +export const UseCommunicationEvent = (type: string, handler: (event: NitroEvent) => void) => UseEventDispatcherHook(type, GetCommunication().events, handler); diff --git a/src/hooks/events/core/UseConfigurationEvent.tsx b/src/hooks/events/core/UseConfigurationEvent.tsx new file mode 100644 index 00000000..2abbad07 --- /dev/null +++ b/src/hooks/events/core/UseConfigurationEvent.tsx @@ -0,0 +1,5 @@ +import { NitroEvent } from '@nitrots/nitro-renderer'; +import { GetConfigurationManager } from '../../../api'; +import { UseEventDispatcherHook } from '../UseEventDispatcherHook'; + +export const UseConfigurationEvent = (type: string, handler: (event: NitroEvent) => void) => UseEventDispatcherHook(type, GetConfigurationManager().events, handler); diff --git a/src/hooks/events/core/communication/communication-event.tsx b/src/hooks/events/core/communication/communication-event.tsx deleted file mode 100644 index e727ba5c..00000000 --- a/src/hooks/events/core/communication/communication-event.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { NitroEvent } from '@nitrots/nitro-renderer'; -import { GetCommunication } from '../../../../api'; -import { CreateEventDispatcherHook } from '../../event-dispatcher.base'; - -export function useCommunicationEvent(type: string, handler: (event: NitroEvent) => void): void -{ - CreateEventDispatcherHook(type, GetCommunication().events, handler); -} diff --git a/src/hooks/events/core/communication/index.ts b/src/hooks/events/core/communication/index.ts deleted file mode 100644 index e4f0035e..00000000 --- a/src/hooks/events/core/communication/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './communication-event'; diff --git a/src/hooks/events/core/configuration/configuration-event.tsx b/src/hooks/events/core/configuration/configuration-event.tsx deleted file mode 100644 index 68eee3d5..00000000 --- a/src/hooks/events/core/configuration/configuration-event.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { NitroEvent } from '@nitrots/nitro-renderer'; -import { GetConfigurationManager } from '../../../../api'; -import { CreateEventDispatcherHook } from '../../event-dispatcher.base'; - -export function useConfigurationEvent(type: string, handler: (event: NitroEvent) => void): void -{ - CreateEventDispatcherHook(type, GetConfigurationManager().events, handler); -} diff --git a/src/hooks/events/core/configuration/index.ts b/src/hooks/events/core/configuration/index.ts deleted file mode 100644 index 30fa7b1b..00000000 --- a/src/hooks/events/core/configuration/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './configuration-event'; diff --git a/src/hooks/events/core/index.ts b/src/hooks/events/core/index.ts index d344bc2c..eca8c2d4 100644 --- a/src/hooks/events/core/index.ts +++ b/src/hooks/events/core/index.ts @@ -1,2 +1,2 @@ -export * from './communication'; -export * from './configuration'; +export * from './UseCommunicationEvent'; +export * from './UseConfigurationEvent'; diff --git a/src/hooks/events/event-dispatcher.base.tsx b/src/hooks/events/event-dispatcher.base.tsx deleted file mode 100644 index ed4702d8..00000000 --- a/src/hooks/events/event-dispatcher.base.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { IEventDispatcher, NitroEvent } from '@nitrots/nitro-renderer'; -import { useEffect } from 'react'; - -export const CreateEventDispatcherHook = (type: string, eventDispatcher: IEventDispatcher, handler: (event: NitroEvent) => void) => -{ - return useEffect(() => - { - eventDispatcher.addEventListener(type, handler); - - return () => - { - eventDispatcher.removeEventListener(type, handler); - } - }, [ type, eventDispatcher, handler ]); -} - -export const DispatchEventHook = (eventDispatcher: IEventDispatcher, event: NitroEvent) => -{ - eventDispatcher.dispatchEvent(event); -} diff --git a/src/hooks/events/index.ts b/src/hooks/events/index.ts index 03d926d1..2d7040fe 100644 --- a/src/hooks/events/index.ts +++ b/src/hooks/events/index.ts @@ -1,4 +1,5 @@ export * from './core'; -export * from './event-dispatcher.base'; +export * from './DispatchEventHook'; export * from './nitro'; export * from './ui'; +export * from './UseEventDispatcherHook'; diff --git a/src/hooks/events/nitro/DispatchMainEvent.ts b/src/hooks/events/nitro/DispatchMainEvent.ts new file mode 100644 index 00000000..d212c666 --- /dev/null +++ b/src/hooks/events/nitro/DispatchMainEvent.ts @@ -0,0 +1,5 @@ +import { NitroEvent } from '@nitrots/nitro-renderer'; +import { GetNitroInstance } from '../../../api'; +import { DispatchEventHook } from '../DispatchEventHook'; + +export const DispatchMainEvent = (event: NitroEvent) => DispatchEventHook(GetNitroInstance().events, event); diff --git a/src/hooks/events/nitro/UseAvatarEvent.tsx b/src/hooks/events/nitro/UseAvatarEvent.tsx new file mode 100644 index 00000000..a7eed8a0 --- /dev/null +++ b/src/hooks/events/nitro/UseAvatarEvent.tsx @@ -0,0 +1,5 @@ +import { NitroEvent } from '@nitrots/nitro-renderer'; +import { GetAvatarRenderManager } from '../../../api'; +import { UseEventDispatcherHook } from '../UseEventDispatcherHook'; + +export const UseAvatarEvent = (type: string, handler: (event: NitroEvent) => void) => UseEventDispatcherHook(type, GetAvatarRenderManager().events, handler); diff --git a/src/hooks/events/nitro/UseCameraEvent.tsx b/src/hooks/events/nitro/UseCameraEvent.tsx new file mode 100644 index 00000000..635b4879 --- /dev/null +++ b/src/hooks/events/nitro/UseCameraEvent.tsx @@ -0,0 +1,5 @@ +import { NitroEvent } from '@nitrots/nitro-renderer'; +import { GetNitroInstance } from '../../../api'; +import { UseEventDispatcherHook } from '../UseEventDispatcherHook'; + +export const UseCameraEvent = (type: string, handler: (event: NitroEvent) => void) => UseEventDispatcherHook(type, GetNitroInstance().cameraManager.events, handler); diff --git a/src/hooks/events/nitro/UseLocalizationEvent.tsx b/src/hooks/events/nitro/UseLocalizationEvent.tsx new file mode 100644 index 00000000..5bd91090 --- /dev/null +++ b/src/hooks/events/nitro/UseLocalizationEvent.tsx @@ -0,0 +1,5 @@ +import { NitroEvent } from '@nitrots/nitro-renderer'; +import { GetNitroInstance } from '../../../api'; +import { UseEventDispatcherHook } from '../UseEventDispatcherHook'; + +export const UseLocalizationEvent = (type: string, handler: (event: NitroEvent) => void) => UseEventDispatcherHook(type, GetNitroInstance().localization.events, handler); diff --git a/src/hooks/events/nitro/UseMainEvent.tsx b/src/hooks/events/nitro/UseMainEvent.tsx new file mode 100644 index 00000000..41f8203b --- /dev/null +++ b/src/hooks/events/nitro/UseMainEvent.tsx @@ -0,0 +1,5 @@ +import { NitroEvent } from '@nitrots/nitro-renderer'; +import { GetNitroInstance } from '../../../api'; +import { UseEventDispatcherHook } from '../UseEventDispatcherHook'; + +export const UseMainEvent = (type: string, handler: (event: NitroEvent) => void) => UseEventDispatcherHook(type, GetNitroInstance().events, handler); diff --git a/src/hooks/events/nitro/UseRoomEngineEvent.tsx b/src/hooks/events/nitro/UseRoomEngineEvent.tsx new file mode 100644 index 00000000..e0c4b547 --- /dev/null +++ b/src/hooks/events/nitro/UseRoomEngineEvent.tsx @@ -0,0 +1,5 @@ +import { NitroEvent } from '@nitrots/nitro-renderer'; +import { GetRoomEngine } from '../../../api'; +import { UseEventDispatcherHook } from '../UseEventDispatcherHook'; + +export const UseRoomEngineEvent = (type: string, handler: (event: NitroEvent) => void) => UseEventDispatcherHook(type, GetRoomEngine().events, handler); diff --git a/src/hooks/events/nitro/UseRoomSessionManagerEvent.tsx b/src/hooks/events/nitro/UseRoomSessionManagerEvent.tsx new file mode 100644 index 00000000..02d65be7 --- /dev/null +++ b/src/hooks/events/nitro/UseRoomSessionManagerEvent.tsx @@ -0,0 +1,5 @@ +import { NitroEvent } from '@nitrots/nitro-renderer'; +import { GetRoomSessionManager } from '../../../api'; +import { UseEventDispatcherHook } from '../UseEventDispatcherHook'; + +export const UseRoomSessionManagerEvent = (type: string, handler: (event: NitroEvent) => void) => UseEventDispatcherHook(type, GetRoomSessionManager().events, handler); diff --git a/src/hooks/events/nitro/UseSessionDataManagerEvent.tsx b/src/hooks/events/nitro/UseSessionDataManagerEvent.tsx new file mode 100644 index 00000000..79f4267d --- /dev/null +++ b/src/hooks/events/nitro/UseSessionDataManagerEvent.tsx @@ -0,0 +1,5 @@ +import { NitroEvent } from '@nitrots/nitro-renderer'; +import { GetSessionDataManager } from '../../../api'; +import { UseEventDispatcherHook } from '../UseEventDispatcherHook'; + +export const UseSessionDataManagerEvent = (type: string, handler: (event: NitroEvent) => void) => UseEventDispatcherHook(type, GetSessionDataManager().events, handler); diff --git a/src/hooks/events/nitro/avatar/avatar-event.tsx b/src/hooks/events/nitro/avatar/avatar-event.tsx deleted file mode 100644 index cf57aee6..00000000 --- a/src/hooks/events/nitro/avatar/avatar-event.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { NitroEvent } from '@nitrots/nitro-renderer'; -import { GetAvatarRenderManager } from '../../../../api'; -import { CreateEventDispatcherHook } from '../../event-dispatcher.base'; - -export function useAvatarEvent(type: string, handler: (event: NitroEvent) => void): void -{ - CreateEventDispatcherHook(type, GetAvatarRenderManager().events, handler); -} diff --git a/src/hooks/events/nitro/avatar/index.ts b/src/hooks/events/nitro/avatar/index.ts deleted file mode 100644 index 57f80c88..00000000 --- a/src/hooks/events/nitro/avatar/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './avatar-event'; diff --git a/src/hooks/events/nitro/camera/camera-event.tsx b/src/hooks/events/nitro/camera/camera-event.tsx deleted file mode 100644 index 3e90f741..00000000 --- a/src/hooks/events/nitro/camera/camera-event.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { NitroEvent } from '@nitrots/nitro-renderer'; -import { GetNitroInstance } from '../../../../api'; -import { CreateEventDispatcherHook } from '../../event-dispatcher.base'; - -export function useCameraEvent(type: string, handler: (event: NitroEvent) => void): void -{ - CreateEventDispatcherHook(type, GetNitroInstance().cameraManager.events, handler); -} diff --git a/src/hooks/events/nitro/camera/index.ts b/src/hooks/events/nitro/camera/index.ts deleted file mode 100644 index 76bf31e0..00000000 --- a/src/hooks/events/nitro/camera/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './camera-event'; diff --git a/src/hooks/events/nitro/index.ts b/src/hooks/events/nitro/index.ts index 262c00cd..56862a78 100644 --- a/src/hooks/events/nitro/index.ts +++ b/src/hooks/events/nitro/index.ts @@ -1,6 +1,8 @@ -export * from './avatar'; -export * from './camera'; -export * from './localization'; -export * from './main-event'; -export * from './room'; -export * from './session'; +export * from './DispatchMainEvent'; +export * from './UseAvatarEvent'; +export * from './UseCameraEvent'; +export * from './UseLocalizationEvent'; +export * from './UseMainEvent'; +export * from './UseRoomEngineEvent'; +export * from './UseRoomSessionManagerEvent'; +export * from './UseSessionDataManagerEvent'; diff --git a/src/hooks/events/nitro/localization/index.ts b/src/hooks/events/nitro/localization/index.ts deleted file mode 100644 index 246da118..00000000 --- a/src/hooks/events/nitro/localization/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './localization-event'; diff --git a/src/hooks/events/nitro/localization/localization-event.tsx b/src/hooks/events/nitro/localization/localization-event.tsx deleted file mode 100644 index 8e3fbb87..00000000 --- a/src/hooks/events/nitro/localization/localization-event.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { NitroEvent } from '@nitrots/nitro-renderer'; -import { GetNitroInstance } from '../../../../api'; -import { CreateEventDispatcherHook } from '../../event-dispatcher.base'; - -export function useLocalizationEvent(type: string, handler: (event: NitroEvent) => void): void -{ - CreateEventDispatcherHook(type, GetNitroInstance().localization.events, handler); -} diff --git a/src/hooks/events/nitro/main-event.tsx b/src/hooks/events/nitro/main-event.tsx deleted file mode 100644 index 92fa3146..00000000 --- a/src/hooks/events/nitro/main-event.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { NitroEvent } from '@nitrots/nitro-renderer'; -import { GetNitroInstance } from '../../../api'; -import { CreateEventDispatcherHook, DispatchEventHook } from '../event-dispatcher.base'; - -export function useMainEvent(type: string, handler: (event: NitroEvent) => void): void -{ - CreateEventDispatcherHook(type, GetNitroInstance().events, handler); -} - -export function dispatchMainEvent(event: NitroEvent): void -{ - DispatchEventHook(GetNitroInstance().events, event); -} diff --git a/src/hooks/events/nitro/room/index.ts b/src/hooks/events/nitro/room/index.ts deleted file mode 100644 index 126d5c40..00000000 --- a/src/hooks/events/nitro/room/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './room-engine-event'; diff --git a/src/hooks/events/nitro/room/room-engine-event.tsx b/src/hooks/events/nitro/room/room-engine-event.tsx deleted file mode 100644 index 7be1ad21..00000000 --- a/src/hooks/events/nitro/room/room-engine-event.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { NitroEvent } from '@nitrots/nitro-renderer'; -import { GetRoomEngine } from '../../../../api'; -import { CreateEventDispatcherHook } from '../../event-dispatcher.base'; - -export function useRoomEngineEvent(type: string, handler: (event: NitroEvent) => void): void -{ - CreateEventDispatcherHook(type, GetRoomEngine().events, handler); -} diff --git a/src/hooks/events/nitro/session/index.ts b/src/hooks/events/nitro/session/index.ts deleted file mode 100644 index 9c12e690..00000000 --- a/src/hooks/events/nitro/session/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './room-session-manager-event'; -export * from './session-data-manager-event'; diff --git a/src/hooks/events/nitro/session/room-session-manager-event.tsx b/src/hooks/events/nitro/session/room-session-manager-event.tsx deleted file mode 100644 index 0ebcee31..00000000 --- a/src/hooks/events/nitro/session/room-session-manager-event.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { NitroEvent } from '@nitrots/nitro-renderer'; -import { GetRoomSessionManager } from '../../../../api'; -import { CreateEventDispatcherHook } from '../../event-dispatcher.base'; - -export function useRoomSessionManagerEvent(type: string, handler: (event: NitroEvent) => void): void -{ - CreateEventDispatcherHook(type, GetRoomSessionManager().events, handler); -} diff --git a/src/hooks/events/nitro/session/session-data-manager-event.tsx b/src/hooks/events/nitro/session/session-data-manager-event.tsx deleted file mode 100644 index 176b29e1..00000000 --- a/src/hooks/events/nitro/session/session-data-manager-event.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { NitroEvent } from '@nitrots/nitro-renderer'; -import { GetSessionDataManager } from '../../../../api'; -import { CreateEventDispatcherHook } from '../../event-dispatcher.base'; - -export function useSessionDataManagerEvent(type: string, handler: (event: NitroEvent) => void): void -{ - CreateEventDispatcherHook(type, GetSessionDataManager().events, handler); -} diff --git a/src/hooks/events/ui/DispatchUiEvent.ts b/src/hooks/events/ui/DispatchUiEvent.ts new file mode 100644 index 00000000..bd88e3ba --- /dev/null +++ b/src/hooks/events/ui/DispatchUiEvent.ts @@ -0,0 +1,5 @@ +import { NitroEvent } from '@nitrots/nitro-renderer'; +import { DispatchEventHook } from '../DispatchEventHook'; +import { UI_EVENT_DISPATCHER } from './UiEventDispatcher'; + +export const DispatchUiEvent = (event: NitroEvent) => DispatchEventHook(UI_EVENT_DISPATCHER, event); diff --git a/src/hooks/events/ui/UiEventDispatcher.ts b/src/hooks/events/ui/UiEventDispatcher.ts new file mode 100644 index 00000000..cb573117 --- /dev/null +++ b/src/hooks/events/ui/UiEventDispatcher.ts @@ -0,0 +1,3 @@ +import { EventDispatcher, IEventDispatcher } from '@nitrots/nitro-renderer'; + +export const UI_EVENT_DISPATCHER: IEventDispatcher = new EventDispatcher(); diff --git a/src/hooks/events/ui/UseUiEvent.tsx b/src/hooks/events/ui/UseUiEvent.tsx new file mode 100644 index 00000000..56797d8f --- /dev/null +++ b/src/hooks/events/ui/UseUiEvent.tsx @@ -0,0 +1,5 @@ +import { NitroEvent } from '@nitrots/nitro-renderer'; +import { UseEventDispatcherHook } from '../UseEventDispatcherHook'; +import { UI_EVENT_DISPATCHER } from './UiEventDispatcher'; + +export const UseUiEvent = (type: string, handler: (event: NitroEvent) => void) => UseEventDispatcherHook(type, UI_EVENT_DISPATCHER, handler); diff --git a/src/hooks/events/ui/index.ts b/src/hooks/events/ui/index.ts index 4c0daa08..5da2c747 100644 --- a/src/hooks/events/ui/index.ts +++ b/src/hooks/events/ui/index.ts @@ -1 +1,3 @@ -export * from './ui-event'; +export * from './DispatchUiEvent'; +export * from './UiEventDispatcher'; +export * from './UseUiEvent'; diff --git a/src/hooks/events/ui/ui-event.tsx b/src/hooks/events/ui/ui-event.tsx deleted file mode 100644 index 99a546e6..00000000 --- a/src/hooks/events/ui/ui-event.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { EventDispatcher, IEventDispatcher, NitroEvent } from '@nitrots/nitro-renderer'; -import { CreateEventDispatcherHook, DispatchEventHook } from '../event-dispatcher.base'; - -const uiEventDispatcher: IEventDispatcher = new EventDispatcher(); - -export const useUiEvent = (type: string, handler: (event: NitroEvent) => void) => -{ - return CreateEventDispatcherHook(type, uiEventDispatcher, handler); -} - -export function dispatchUiEvent(event: NitroEvent): void -{ - DispatchEventHook(uiEventDispatcher, event); -} diff --git a/src/hooks/messages/UseMessageEventHook.tsx b/src/hooks/messages/UseMessageEventHook.tsx new file mode 100644 index 00000000..cc785573 --- /dev/null +++ b/src/hooks/messages/UseMessageEventHook.tsx @@ -0,0 +1,16 @@ +import { IMessageEvent, MessageEvent } from '@nitrots/nitro-renderer'; +import { useEffect } from 'react'; +import { GetCommunication } from '../../api'; + +export function UseMessageEventHook(eventType: typeof MessageEvent, handler: (event: IMessageEvent) => void): void +{ + useEffect(() => + { + //@ts-ignore + const event = new eventType(handler); + + GetCommunication().registerMessageEvent(event); + + return () => GetCommunication().removeMessageEvent(event); + }, [ eventType, handler ]); +} diff --git a/src/hooks/messages/index.ts b/src/hooks/messages/index.ts index bd1eb301..46b80a45 100644 --- a/src/hooks/messages/index.ts +++ b/src/hooks/messages/index.ts @@ -1 +1 @@ -export * from './message-event'; +export * from './UseMessageEventHook'; diff --git a/src/hooks/messages/message-event.tsx b/src/hooks/messages/message-event.tsx deleted file mode 100644 index bd855ec7..00000000 --- a/src/hooks/messages/message-event.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { IMessageComposer, IMessageEvent, MessageEvent } from '@nitrots/nitro-renderer'; -import { useEffect } from 'react'; -import { GetCommunication, GetConnection } from '../../api'; - -export function CreateMessageHook(eventType: typeof MessageEvent, handler: (event: IMessageEvent) => void): void -{ - useEffect(() => - { - //@ts-ignore - const event = new eventType(handler); - - GetCommunication().registerMessageEvent(event); - - return () => GetCommunication().removeMessageEvent(event); - }, [ eventType, handler ]); -} - -export function SendMessageHook(event: IMessageComposer): void -{ - GetConnection().send(event); -} diff --git a/src/views/campaign/CampaignView.tsx b/src/views/campaign/CampaignView.tsx index 2178333d..d207f67c 100644 --- a/src/views/campaign/CampaignView.tsx +++ b/src/views/campaign/CampaignView.tsx @@ -1,7 +1,7 @@ import { CampaignCalendarData, CampaignCalendarDataMessageEvent, CampaignCalendarDoorOpenedMessageEvent, OpenCampaignCalendarDoorAsStaffComposer, OpenCampaignCalendarDoorComposer } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; -import { AddEventLinkTracker, RemoveLinkEventTracker } from '../../api'; -import { BatchUpdates, CreateMessageHook, SendMessageHook } from '../../hooks'; +import { AddEventLinkTracker, RemoveLinkEventTracker, SendMessageComposer } from '../../api'; +import { BatchUpdates, UseMessageEventHook } from '../../hooks'; import { CalendarView } from './views/calendar/CalendarView'; export const CampaignView: FC<{}> = props => @@ -19,7 +19,7 @@ export const CampaignView: FC<{}> = props => setCalendarData(parser.calendarData); }, []); - CreateMessageHook(CampaignCalendarDataMessageEvent, onCampaignCalendarDataMessageEvent); + UseMessageEventHook(CampaignCalendarDataMessageEvent, onCampaignCalendarDataMessageEvent); const onCampaignCalendarDoorOpenedMessageEvent = useCallback((event: CampaignCalendarDoorOpenedMessageEvent) => { @@ -54,7 +54,7 @@ export const CampaignView: FC<{}> = props => setLastOpenAttempt(-1); }, [lastOpenAttempt]); - CreateMessageHook(CampaignCalendarDoorOpenedMessageEvent, onCampaignCalendarDoorOpenedMessageEvent); + UseMessageEventHook(CampaignCalendarDoorOpenedMessageEvent, onCampaignCalendarDoorOpenedMessageEvent); const openPackage = useCallback((id: number, asStaff = false) => { @@ -64,12 +64,12 @@ export const CampaignView: FC<{}> = props => if(asStaff) { - SendMessageHook(new OpenCampaignCalendarDoorAsStaffComposer(calendarData.campaignName, id)); + SendMessageComposer(new OpenCampaignCalendarDoorAsStaffComposer(calendarData.campaignName, id)); } else { - SendMessageHook(new OpenCampaignCalendarDoorComposer(calendarData.campaignName, id)); + SendMessageComposer(new OpenCampaignCalendarDoorComposer(calendarData.campaignName, id)); } }, [calendarData]); diff --git a/src/views/floorplan-editor/FloorplanEditorView.tsx b/src/views/floorplan-editor/FloorplanEditorView.tsx index 8fc4fd74..f015e0e6 100644 --- a/src/views/floorplan-editor/FloorplanEditorView.tsx +++ b/src/views/floorplan-editor/FloorplanEditorView.tsx @@ -1,9 +1,9 @@ import { FloorHeightMapEvent, NitroPoint, RoomEngineEvent, RoomVisualizationSettingsEvent, UpdateFloorPropertiesMessageComposer } from '@nitrots/nitro-renderer'; import { FC, useCallback, useState } from 'react'; -import { LocalizeText } from '../../api'; +import { LocalizeText, SendMessageComposer } from '../../api'; import { Column, Flex, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../common'; -import { FloorplanEditorEvent } from '../../events/floorplan-editor/FloorplanEditorEvent'; -import { CreateMessageHook, SendMessageHook, UseMountEffect, useRoomEngineEvent, useUiEvent } from '../../hooks'; +import { FloorplanEditorEvent } from '../../events'; +import { UseMessageEventHook, UseMountEffect, UseRoomEngineEvent, UseUiEvent } from '../../hooks'; import { FloorplanEditor } from './common/FloorplanEditor'; import { convertNumbersForSaving, convertSettingToNumber } from './common/Utils'; import { FloorplanEditorContextProvider } from './context/FloorplanEditorContext'; @@ -41,9 +41,9 @@ export const FloorplanEditorView: FC<{}> = props => } }, [isVisible]); - useUiEvent(FloorplanEditorEvent.HIDE_FLOORPLAN_EDITOR, onFloorplanEditorEvent); - useUiEvent(FloorplanEditorEvent.SHOW_FLOORPLAN_EDITOR, onFloorplanEditorEvent); - useUiEvent(FloorplanEditorEvent.TOGGLE_FLOORPLAN_EDITOR, onFloorplanEditorEvent); + UseUiEvent(FloorplanEditorEvent.HIDE_FLOORPLAN_EDITOR, onFloorplanEditorEvent); + UseUiEvent(FloorplanEditorEvent.SHOW_FLOORPLAN_EDITOR, onFloorplanEditorEvent); + UseUiEvent(FloorplanEditorEvent.TOGGLE_FLOORPLAN_EDITOR, onFloorplanEditorEvent); UseMountEffect(() => { @@ -55,7 +55,7 @@ export const FloorplanEditorView: FC<{}> = props => setIsVisible(false); }, []); - useRoomEngineEvent(RoomEngineEvent.DISPOSED, onRoomEngineEvent); + UseRoomEngineEvent(RoomEngineEvent.DISPOSED, onRoomEngineEvent); const onFloorHeightMapEvent = useCallback((event: FloorHeightMapEvent) => { @@ -74,7 +74,7 @@ export const FloorplanEditorView: FC<{}> = props => }, [originalFloorplanSettings, visualizationSettings]); - CreateMessageHook(FloorHeightMapEvent, onFloorHeightMapEvent); + UseMessageEventHook(FloorHeightMapEvent, onFloorHeightMapEvent); const onRoomVisualizationSettingsEvent = useCallback((event: RoomVisualizationSettingsEvent) => { @@ -94,11 +94,11 @@ export const FloorplanEditorView: FC<{}> = props => setVisualizationSettings(vSettings); }, [originalFloorplanSettings, visualizationSettings]); - CreateMessageHook(RoomVisualizationSettingsEvent, onRoomVisualizationSettingsEvent); + UseMessageEventHook(RoomVisualizationSettingsEvent, onRoomVisualizationSettingsEvent); const saveFloorChanges = useCallback(() => { - SendMessageHook(new UpdateFloorPropertiesMessageComposer( + SendMessageComposer(new UpdateFloorPropertiesMessageComposer( FloorplanEditor.instance.getCurrentTilemapString(), FloorplanEditor.instance.doorLocation.x, FloorplanEditor.instance.doorLocation.y, diff --git a/src/views/floorplan-editor/views/FloorplanCanvasView.tsx b/src/views/floorplan-editor/views/FloorplanCanvasView.tsx index be79a2e6..2cca5cea 100644 --- a/src/views/floorplan-editor/views/FloorplanCanvasView.tsx +++ b/src/views/floorplan-editor/views/FloorplanCanvasView.tsx @@ -1,7 +1,8 @@ import { GetOccupiedTilesMessageComposer, GetRoomEntryTileMessageComposer, NitroPoint, RoomEntryTileMessageEvent, RoomOccupiedTilesMessageEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useRef, useState } from 'react'; +import { SendMessageComposer } from '../../../api'; import { Flex } from '../../../common'; -import { CreateMessageHook, SendMessageHook, UseMountEffect } from '../../../hooks'; +import { UseMessageEventHook, UseMountEffect } from '../../../hooks'; import { FloorplanEditor } from '../common/FloorplanEditor'; import { useFloorplanEditorContext } from '../context/FloorplanEditorContext'; @@ -23,8 +24,8 @@ export const FloorplanCanvasView: FC<{}> = props => UseMountEffect(() => { - SendMessageHook(new GetRoomEntryTileMessageComposer()); - SendMessageHook(new GetOccupiedTilesMessageComposer()); + SendMessageComposer(new GetRoomEntryTileMessageComposer()); + SendMessageComposer(new GetOccupiedTilesMessageComposer()); FloorplanEditor.instance.tilemapRenderer.interactive = true; elementRef.current.appendChild(FloorplanEditor.instance.renderer.view); }); @@ -46,7 +47,7 @@ export const FloorplanCanvasView: FC<{}> = props => elementRef.current.scrollTo(FloorplanEditor.instance.view.width / 3, 0); }, [originalFloorplanSettings, setOriginalFloorplanSettings]); - CreateMessageHook(RoomOccupiedTilesMessageEvent, onRoomOccupiedTilesMessageEvent); + UseMessageEventHook(RoomOccupiedTilesMessageEvent, onRoomOccupiedTilesMessageEvent); const onRoomEntryTileMessageEvent = useCallback((event: RoomEntryTileMessageEvent) => { @@ -67,7 +68,7 @@ export const FloorplanCanvasView: FC<{}> = props => setEntryTileReceived(true); }, [originalFloorplanSettings, setOriginalFloorplanSettings, setVisualizationSettings, visualizationSettings]); - CreateMessageHook(RoomEntryTileMessageEvent, onRoomEntryTileMessageEvent); + UseMessageEventHook(RoomEntryTileMessageEvent, onRoomEntryTileMessageEvent); const onClickArrowButton = useCallback((scrollDirection: string) => { diff --git a/src/views/floorplan-editor/views/FloorplanImportExportView.tsx b/src/views/floorplan-editor/views/FloorplanImportExportView.tsx index c0b5994f..752c1230 100644 --- a/src/views/floorplan-editor/views/FloorplanImportExportView.tsx +++ b/src/views/floorplan-editor/views/FloorplanImportExportView.tsx @@ -1,8 +1,8 @@ import { UpdateFloorPropertiesMessageComposer } from '@nitrots/nitro-renderer'; import { FC, useCallback, useState } from 'react'; -import { LocalizeText } from '../../../api'; +import { LocalizeText, SendMessageComposer } from '../../../api'; import { Column, Flex, NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../common'; -import { SendMessageHook, UseMountEffect } from '../../../hooks'; +import { UseMountEffect } from '../../../hooks'; import { convertNumbersForSaving } from '../common/Utils'; import { useFloorplanEditorContext } from '../context/FloorplanEditorContext'; @@ -25,7 +25,7 @@ export const FloorplanImportExportView: FC = pro const saveFloorChanges = useCallback(() => { - SendMessageHook(new UpdateFloorPropertiesMessageComposer( + SendMessageComposer(new UpdateFloorPropertiesMessageComposer( map.split('\n').join('\r'), originalFloorplanSettings.entryPoint[0], originalFloorplanSettings.entryPoint[1], diff --git a/src/views/friends/FriendsView.tsx b/src/views/friends/FriendsView.tsx index a468628d..0f4bb3ca 100644 --- a/src/views/friends/FriendsView.tsx +++ b/src/views/friends/FriendsView.tsx @@ -2,12 +2,9 @@ import { AcceptFriendMessageComposer, FriendListFragmentEvent, FriendListUpdateE import { DeclineFriendMessageComposer } from '@nitrots/nitro-renderer/src'; import { FC, useCallback, useEffect, useMemo, useState } from 'react'; import { createPortal } from 'react-dom'; -import { GetRoomSession } from '../../api'; -import { FriendEnteredRoomEvent, FriendListContentEvent, FriendRequestEvent, FriendsAcceptFriendRequestEvent, FriendsDeclineFriendRequestEvent, FriendsEvent, FriendsRequestCountEvent } from '../../events'; -import { FriendsSendFriendRequestEvent } from '../../events/friends/FriendsSendFriendRequestEvent'; -import { CreateMessageHook, useRoomEngineEvent } from '../../hooks'; -import { dispatchUiEvent, useUiEvent } from '../../hooks/events/ui/ui-event'; -import { SendMessageHook } from '../../hooks/messages/message-event'; +import { GetRoomSession, SendMessageComposer } from '../../api'; +import { FriendEnteredRoomEvent, FriendListContentEvent, FriendRequestEvent, FriendsAcceptFriendRequestEvent, FriendsDeclineFriendRequestEvent, FriendsEvent, FriendsRequestCountEvent, FriendsSendFriendRequestEvent } from '../../events'; +import { DispatchUiEvent, UseMessageEventHook, UseRoomEngineEvent, UseUiEvent } from '../../hooks'; import { FriendsHelper } from './common/FriendsHelper'; import { MessengerFriend } from './common/MessengerFriend'; import { MessengerRequest } from './common/MessengerRequest'; @@ -64,7 +61,7 @@ export const FriendsView: FC<{}> = props => return newSentRequests; }); - SendMessageHook(new RequestFriendComposer(userName)); + SendMessageComposer(new RequestFriendComposer(userName)); }, [ sentRequests, canRequestFriend ]); const acceptFriend = useCallback((userId: number) => @@ -77,9 +74,9 @@ export const FriendsView: FC<{}> = props => if(index >= 0) { - SendMessageHook(new AcceptFriendMessageComposer(newRequests[index].id)); + SendMessageComposer(new AcceptFriendMessageComposer(newRequests[index].id)); - dispatchUiEvent(new FriendRequestEvent(FriendRequestEvent.ACCEPTED, userId)); + DispatchUiEvent(new FriendRequestEvent(FriendRequestEvent.ACCEPTED, userId)); newRequests.splice(index, 1); } @@ -94,9 +91,9 @@ export const FriendsView: FC<{}> = props => { if(declineAll) { - SendMessageHook(new DeclineFriendMessageComposer(true)); + SendMessageComposer(new DeclineFriendMessageComposer(true)); - for(const request of prevValue) dispatchUiEvent(new FriendRequestEvent(FriendRequestEvent.DECLINED, request.requesterUserId)); + for(const request of prevValue) DispatchUiEvent(new FriendRequestEvent(FriendRequestEvent.DECLINED, request.requesterUserId)); return []; } @@ -108,9 +105,9 @@ export const FriendsView: FC<{}> = props => if(index >= 0) { - SendMessageHook(new DeclineFriendMessageComposer(false, newRequests[index].id)); + SendMessageComposer(new DeclineFriendMessageComposer(false, newRequests[index].id)); - dispatchUiEvent(new FriendRequestEvent(FriendRequestEvent.DECLINED, userId)); + DispatchUiEvent(new FriendRequestEvent(FriendRequestEvent.DECLINED, userId)); newRequests.splice(index, 1); } @@ -130,10 +127,10 @@ export const FriendsView: FC<{}> = props => parser.extendedFriendLimit, parser.categories)); - SendMessageHook(new GetFriendRequestsComposer()); + SendMessageComposer(new GetFriendRequestsComposer()); }, []); - CreateMessageHook(MessengerInitEvent, onMessengerInitEvent); + UseMessageEventHook(MessengerInitEvent, onMessengerInitEvent); const onFriendsFragmentEvent = useCallback((event: FriendListFragmentEvent) => { @@ -158,7 +155,7 @@ export const FriendsView: FC<{}> = props => }); }, []); - CreateMessageHook(FriendListFragmentEvent, onFriendsFragmentEvent); + UseMessageEventHook(FriendListFragmentEvent, onFriendsFragmentEvent); const onFriendsUpdateEvent = useCallback((event: FriendListUpdateEvent) => { @@ -200,7 +197,7 @@ export const FriendsView: FC<{}> = props => }); }, []); - CreateMessageHook(FriendListUpdateEvent, onFriendsUpdateEvent); + UseMessageEventHook(FriendListUpdateEvent, onFriendsUpdateEvent); const onFriendRequestsEvent = useCallback((event: FriendRequestsEvent) => { @@ -226,7 +223,7 @@ export const FriendsView: FC<{}> = props => }); }, []); - CreateMessageHook(FriendRequestsEvent, onFriendRequestsEvent); + UseMessageEventHook(FriendRequestsEvent, onFriendRequestsEvent); const onNewFriendRequestEvent = useCallback((event: NewFriendRequestEvent) => { @@ -251,7 +248,7 @@ export const FriendsView: FC<{}> = props => }); }, []); - CreateMessageHook(NewFriendRequestEvent, onNewFriendRequestEvent); + UseMessageEventHook(NewFriendRequestEvent, onNewFriendRequestEvent); const onFriendsEvent = useCallback((event: FriendsEvent) => { @@ -268,29 +265,29 @@ export const FriendsView: FC<{}> = props => requestFriend(requestEvent.userId, requestEvent.userName); return; case FriendsEvent.REQUEST_FRIEND_LIST: - dispatchUiEvent(new FriendListContentEvent(friends)); + DispatchUiEvent(new FriendListContentEvent(friends)); return; } }, [ friends, requestFriend ]); - useUiEvent(FriendsEvent.SHOW_FRIEND_LIST, onFriendsEvent); - useUiEvent(FriendsEvent.TOGGLE_FRIEND_LIST, onFriendsEvent); - useUiEvent(FriendsSendFriendRequestEvent.SEND_FRIEND_REQUEST, onFriendsEvent); - useUiEvent(FriendsEvent.REQUEST_FRIEND_LIST, onFriendsEvent); + UseUiEvent(FriendsEvent.SHOW_FRIEND_LIST, onFriendsEvent); + UseUiEvent(FriendsEvent.TOGGLE_FRIEND_LIST, onFriendsEvent); + UseUiEvent(FriendsSendFriendRequestEvent.SEND_FRIEND_REQUEST, onFriendsEvent); + UseUiEvent(FriendsEvent.REQUEST_FRIEND_LIST, onFriendsEvent); const onFriendsAcceptFriendRequestEvent = useCallback((event: FriendsAcceptFriendRequestEvent) => { acceptFriend(event.requestId); }, [ acceptFriend ]); - useUiEvent(FriendsAcceptFriendRequestEvent.ACCEPT_FRIEND_REQUEST, onFriendsAcceptFriendRequestEvent); + UseUiEvent(FriendsAcceptFriendRequestEvent.ACCEPT_FRIEND_REQUEST, onFriendsAcceptFriendRequestEvent); const onFriendsDeclineFriendRequestEvent = useCallback((event: FriendsDeclineFriendRequestEvent) => { declineFriend(event.requestId); }, [ declineFriend ]); - useUiEvent(FriendsDeclineFriendRequestEvent.DECLINE_FRIEND_REQUEST, onFriendsDeclineFriendRequestEvent); + UseUiEvent(FriendsDeclineFriendRequestEvent.DECLINE_FRIEND_REQUEST, onFriendsDeclineFriendRequestEvent); const onRoomEngineObjectEvent = useCallback((event: RoomEngineObjectEvent) => { @@ -308,10 +305,10 @@ export const FriendsView: FC<{}> = props => if(!friend) return; - dispatchUiEvent(new FriendEnteredRoomEvent(userData.roomIndex, RoomObjectCategory.UNIT, userData.webID, userData.name, userData.type)); + DispatchUiEvent(new FriendEnteredRoomEvent(userData.roomIndex, RoomObjectCategory.UNIT, userData.webID, userData.name, userData.type)); }, [ getFriend ]); - useRoomEngineEvent(RoomEngineObjectEvent.ADDED, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineObjectEvent.ADDED, onRoomEngineObjectEvent); const onlineFriends = useMemo(() => { @@ -347,7 +344,7 @@ export const FriendsView: FC<{}> = props => useEffect(() => { - SendMessageHook(new MessengerInitComposer()); + SendMessageComposer(new MessengerInitComposer()); }, []); useEffect(() => @@ -359,7 +356,7 @@ export const FriendsView: FC<{}> = props => useEffect(() => { - dispatchUiEvent(new FriendsRequestCountEvent(requests.length)); + DispatchUiEvent(new FriendsRequestCountEvent(requests.length)); }, [ requests ]); return ( diff --git a/src/views/friends/views/friend-bar/FriendBarItemView.tsx b/src/views/friends/views/friend-bar/FriendBarItemView.tsx index 17609191..81d36d79 100644 --- a/src/views/friends/views/friend-bar/FriendBarItemView.tsx +++ b/src/views/friends/views/friend-bar/FriendBarItemView.tsx @@ -1,8 +1,7 @@ import { FollowFriendMessageComposer, MouseEventType } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useRef, useState } from 'react'; -import { GetUserProfile, LocalizeText, OpenMessengerChat } from '../../../../api'; +import { GetUserProfile, LocalizeText, OpenMessengerChat, SendMessageComposer } from '../../../../api'; import { Base } from '../../../../common'; -import { SendMessageHook } from '../../../../hooks/messages'; import { AvatarImageView } from '../../../shared/avatar-image/AvatarImageView'; import { BadgeImageView } from '../../../shared/badge-image/BadgeImageView'; import { MessengerFriend } from '../../common/MessengerFriend'; @@ -20,7 +19,7 @@ export const FriendBarItemView: FC = props => const followFriend = useCallback(() => { - SendMessageHook(new FollowFriendMessageComposer(friend.id)); + SendMessageComposer(new FollowFriendMessageComposer(friend.id)); }, [ friend ]); const openMessengerChat = useCallback(() => diff --git a/src/views/friends/views/friends-group/FriendsGroupItemView.tsx b/src/views/friends/views/friends-group/FriendsGroupItemView.tsx index b72c4017..35a9ba28 100644 --- a/src/views/friends/views/friends-group/FriendsGroupItemView.tsx +++ b/src/views/friends/views/friends-group/FriendsGroupItemView.tsx @@ -1,9 +1,8 @@ import { FollowFriendMessageComposer, SetRelationshipStatusComposer } from '@nitrots/nitro-renderer'; import classNames from 'classnames'; import { FC, useCallback, useState } from 'react'; -import { LocalizeText, OpenMessengerChat } from '../../../../api'; +import { LocalizeText, OpenMessengerChat, SendMessageComposer } from '../../../../api'; import { Base, Flex, FlexProps, UserProfileIconView } from '../../../../common'; -import { SendMessageHook } from '../../../../hooks'; import { MessengerFriend } from '../../common/MessengerFriend'; interface FriendsGroupItemViewProps extends FlexProps @@ -23,7 +22,7 @@ export const FriendsGroupItemView: FC = props => { if(!friend) return; - SendMessageHook(new FollowFriendMessageComposer(friend.id)); + SendMessageComposer(new FollowFriendMessageComposer(friend.id)); }, [ friend ]); const openMessengerChat = useCallback((e) => @@ -58,7 +57,7 @@ export const FriendsGroupItemView: FC = props => { e.stopPropagation(); - if(type !== friend.relationshipStatus) SendMessageHook(new SetRelationshipStatusComposer(friend.id, type)); + if(type !== friend.relationshipStatus) SendMessageComposer(new SetRelationshipStatusComposer(friend.id, type)); setIsExpanded(false); }, [ friend ]); diff --git a/src/views/friends/views/friends-list/FriendsListView.tsx b/src/views/friends/views/friends-list/FriendsListView.tsx index 964f4342..334c6e78 100644 --- a/src/views/friends/views/friends-list/FriendsListView.tsx +++ b/src/views/friends/views/friends-list/FriendsListView.tsx @@ -1,8 +1,7 @@ import { RemoveFriendComposer, SendRoomInviteComposer } from '@nitrots/nitro-renderer'; import { FC, useCallback, useMemo, useState } from 'react'; -import { LocalizeText } from '../../../../api'; +import { LocalizeText, SendMessageComposer } from '../../../../api'; import { NitroCardAccordionSetView, NitroCardAccordionView, NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../../../common'; -import { SendMessageHook } from '../../../../hooks'; import { MessengerFriend } from '../../common/MessengerFriend'; import { MessengerRequest } from '../../common/MessengerRequest'; import { FriendsGroupView } from '../friends-group/FriendsGroupView'; @@ -75,7 +74,7 @@ export const FriendsListView: FC = props => { if(selectedFriendsIds.length === 0 || !message || message.length === 0) return; - SendMessageHook(new SendRoomInviteComposer(message, ...selectedFriendsIds)); + SendMessageComposer(new SendRoomInviteComposer(message, ...selectedFriendsIds)); setShowRoomInvite(false); }, [ selectedFriendsIds, setShowRoomInvite ]); @@ -83,7 +82,7 @@ export const FriendsListView: FC = props => { if(selectedFriendsIds.length === 0) return; - SendMessageHook(new RemoveFriendComposer(...selectedFriendsIds)); + SendMessageComposer(new RemoveFriendComposer(...selectedFriendsIds)); setSelectedFriendsIds([]); setShowRemoveFriendsConfirmation(false); }, [ selectedFriendsIds ]); diff --git a/src/views/friends/views/friends-search/FriendsSearchView.tsx b/src/views/friends/views/friends-search/FriendsSearchView.tsx index ca63dd9b..886dda13 100644 --- a/src/views/friends/views/friends-search/FriendsSearchView.tsx +++ b/src/views/friends/views/friends-search/FriendsSearchView.tsx @@ -1,8 +1,8 @@ import { HabboSearchComposer, HabboSearchResultData, HabboSearchResultEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; -import { LocalizeText, OpenMessengerChat } from '../../../../api'; +import { LocalizeText, OpenMessengerChat, SendMessageComposer } from '../../../../api'; import { Base, Flex, NitroCardAccordionItemView, NitroCardAccordionSetView, NitroCardAccordionView, UserProfileIconView } from '../../../../common'; -import { BatchUpdates, CreateMessageHook, SendMessageHook } from '../../../../hooks'; +import { BatchUpdates, UseMessageEventHook } from '../../../../hooks'; import { useFriendsContext } from '../../FriendsContext'; export const FriendsSearchView: FC<{}> = props => @@ -23,7 +23,7 @@ export const FriendsSearchView: FC<{}> = props => }); }, []); - CreateMessageHook(HabboSearchResultEvent, onHabboSearchResultEvent); + UseMessageEventHook(HabboSearchResultEvent, onHabboSearchResultEvent); useEffect(() => { @@ -33,7 +33,7 @@ export const FriendsSearchView: FC<{}> = props => { if(!searchValue || !searchValue.length) return; - SendMessageHook(new HabboSearchComposer(searchValue)); + SendMessageComposer(new HabboSearchComposer(searchValue)); }, 500); return () => clearTimeout(timeout); diff --git a/src/views/friends/views/messenger/FriendsMessengerView.tsx b/src/views/friends/views/messenger/FriendsMessengerView.tsx index c5deb6ae..edd45820 100644 --- a/src/views/friends/views/messenger/FriendsMessengerView.tsx +++ b/src/views/friends/views/messenger/FriendsMessengerView.tsx @@ -1,10 +1,9 @@ -import { FollowFriendMessageComposer, ILinkEventTracker, NewConsoleMessageEvent, RoomInviteEvent, SendMessageComposer } from '@nitrots/nitro-renderer'; +import { FollowFriendMessageComposer, ILinkEventTracker, NewConsoleMessageEvent, RoomInviteEvent, SendMessageComposer as SendMessageComposerPacket } from '@nitrots/nitro-renderer'; import { FC, KeyboardEvent, useCallback, useEffect, useMemo, useRef, useState } from 'react'; -import { AddEventLinkTracker, GetSessionDataManager, GetUserProfile, LocalizeText, RemoveLinkEventTracker } from '../../../../api'; -import { MESSENGER_MESSAGE_RECEIVED, MESSENGER_NEW_THREAD, PlaySound } from '../../../../api/utils/PlaySound'; +import { AddEventLinkTracker, GetSessionDataManager, GetUserProfile, LocalizeText, MESSENGER_MESSAGE_RECEIVED, MESSENGER_NEW_THREAD, PlaySound, RemoveLinkEventTracker, SendMessageComposer } from '../../../../api'; import { Base, Button, ButtonGroup, Column, Flex, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../common'; import { FriendsMessengerIconEvent } from '../../../../events'; -import { BatchUpdates, CreateMessageHook, dispatchUiEvent, SendMessageHook } from '../../../../hooks'; +import { BatchUpdates, DispatchUiEvent, UseMessageEventHook } from '../../../../hooks'; import { AvatarImageView } from '../../../shared/avatar-image/AvatarImageView'; import { BadgeImageView } from '../../../shared/badge-image/BadgeImageView'; import { ItemCountView } from '../../../shared/item-count/ItemCountView'; @@ -26,7 +25,7 @@ export const FriendsMessengerView: FC<{}> = props => const followFriend = useCallback(() => { - SendMessageHook(new FollowFriendMessageComposer(messageThreads[activeThreadIndex].participant.id)); + SendMessageComposer(new FollowFriendMessageComposer(messageThreads[activeThreadIndex].participant.id)); }, [messageThreads, activeThreadIndex]); const openProfile = useCallback(() => @@ -102,7 +101,7 @@ export const FriendsMessengerView: FC<{}> = props => setMessageThreads(prevValue => [...prevValue]); }, [getMessageThreadWithIndex]); - CreateMessageHook(NewConsoleMessageEvent, onNewConsoleMessageEvent); + UseMessageEventHook(NewConsoleMessageEvent, onNewConsoleMessageEvent); const onRoomInviteEvent = useCallback((event: RoomInviteEvent) => { @@ -117,7 +116,7 @@ export const FriendsMessengerView: FC<{}> = props => setMessageThreads(prevValue => [...prevValue]); }, [getMessageThreadWithIndex]); - CreateMessageHook(RoomInviteEvent, onRoomInviteEvent); + UseMessageEventHook(RoomInviteEvent, onRoomInviteEvent); const sendMessage = useCallback(() => { @@ -129,7 +128,7 @@ export const FriendsMessengerView: FC<{}> = props => if(!thread) return; - SendMessageHook(new SendMessageComposer(thread.participant.id, messageText)); + SendMessageComposer(new SendMessageComposerPacket(thread.participant.id, messageText)); if(messageThreads.length === 1 && thread.groups.length === 1) PlaySound(MESSENGER_NEW_THREAD); @@ -229,7 +228,7 @@ export const FriendsMessengerView: FC<{}> = props => { setIsVisible(false); - dispatchUiEvent(new FriendsMessengerIconEvent(FriendsMessengerIconEvent.UPDATE_ICON, FriendsMessengerIconEvent.HIDE_ICON)); + DispatchUiEvent(new FriendsMessengerIconEvent(FriendsMessengerIconEvent.UPDATE_ICON, FriendsMessengerIconEvent.HIDE_ICON)); return; } @@ -248,7 +247,7 @@ export const FriendsMessengerView: FC<{}> = props => if(isUnread) PlaySound(MESSENGER_MESSAGE_RECEIVED); - dispatchUiEvent(new FriendsMessengerIconEvent(FriendsMessengerIconEvent.UPDATE_ICON, isUnread ? FriendsMessengerIconEvent.UNREAD_ICON : FriendsMessengerIconEvent.SHOW_ICON)); + DispatchUiEvent(new FriendsMessengerIconEvent(FriendsMessengerIconEvent.UPDATE_ICON, isUnread ? FriendsMessengerIconEvent.UNREAD_ICON : FriendsMessengerIconEvent.SHOW_ICON)); }, [visibleThreads, updateValue]); if(!isVisible) return null; diff --git a/src/views/hc-center/HcCenterView.tsx b/src/views/hc-center/HcCenterView.tsx index f9258d4f..442b5fc8 100644 --- a/src/views/hc-center/HcCenterView.tsx +++ b/src/views/hc-center/HcCenterView.tsx @@ -3,10 +3,10 @@ import { BadgesEvent, FigureUpdateEvent } from '@nitrots/nitro-renderer/src'; import { ScrGetKickbackInfoMessageComposer } from '@nitrots/nitro-renderer/src/nitro/communication/messages/outgoing/user/ScrGetKickbackInfoMessageComposer'; import { FC, useCallback, useEffect, useState } from 'react'; import { OverlayTrigger, Popover } from 'react-bootstrap'; -import { AddEventLinkTracker, CreateLinkEvent, GetConfiguration, LocalizeText, RemoveLinkEventTracker } from '../../api'; +import { AddEventLinkTracker, CreateLinkEvent, GetConfiguration, LocalizeText, RemoveLinkEventTracker, SendMessageComposer } from '../../api'; import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../common'; -import { HcCenterEvent } from '../../events/hc-center/HcCenterEvent'; -import { CreateMessageHook, SendMessageHook, useUiEvent } from '../../hooks'; +import { HcCenterEvent } from '../../events'; +import { UseMessageEventHook, UseUiEvent } from '../../hooks'; import { AvatarImageView } from '../shared/avatar-image/AvatarImageView'; import { BadgeImageView } from '../shared/badge-image/BadgeImageView'; import { BadgeResolver } from './util/BadgeResolver'; @@ -73,8 +73,8 @@ export const HcCenterView: FC<{}> = props => setUserFigure(parser.figure); }, []); - CreateMessageHook(UserInfoEvent, onUserInfoEvent); - CreateMessageHook(FigureUpdateEvent, onUserFigureEvent); + UseMessageEventHook(UserInfoEvent, onUserInfoEvent); + UseMessageEventHook(FigureUpdateEvent, onUserFigureEvent); const onHcCenterEvent = useCallback((event: HcCenterEvent) => { @@ -86,7 +86,7 @@ export const HcCenterView: FC<{}> = props => } }, [isVisible]); - useUiEvent(HcCenterEvent.TOGGLE_HC_CENTER, onHcCenterEvent); + UseUiEvent(HcCenterEvent.TOGGLE_HC_CENTER, onHcCenterEvent); const onClubGiftInfoEvent = useCallback((event: ClubGiftInfoEvent) => { @@ -109,15 +109,15 @@ export const HcCenterView: FC<{}> = props => setBadgeCode(BadgeResolver.getClubBadge(parser.getAllBadgeCodes())); }, []) - CreateMessageHook(ClubGiftInfoEvent, onClubGiftInfoEvent); - CreateMessageHook(ScrSendKickbackInfoMessageEvent, onScrSendKickbackInfo); - CreateMessageHook(BadgesEvent, onBadges); + UseMessageEventHook(ClubGiftInfoEvent, onClubGiftInfoEvent); + UseMessageEventHook(ScrSendKickbackInfoMessageEvent, onScrSendKickbackInfo); + UseMessageEventHook(BadgesEvent, onBadges); useEffect(() => { - SendMessageHook(new GetClubGiftInfo()); - SendMessageHook(new ScrGetKickbackInfoMessageComposer()); - SendMessageHook(new RequestBadgesComposer()); + SendMessageComposer(new GetClubGiftInfo()); + SendMessageComposer(new ScrGetKickbackInfoMessageComposer()); + SendMessageComposer(new RequestBadgesComposer()); }, []); const onUserSubscriptionEvent = useCallback((event: UserSubscriptionEvent) => @@ -141,7 +141,7 @@ export const HcCenterView: FC<{}> = props => }, [clubDays, pastClubDays]); - CreateMessageHook(UserSubscriptionEvent, onUserSubscriptionEvent); + UseMessageEventHook(UserSubscriptionEvent, onUserSubscriptionEvent); const getClubText = useCallback(() => { diff --git a/src/views/hotel-view/HotelView.tsx b/src/views/hotel-view/HotelView.tsx index a4bb33ac..f446b0da 100644 --- a/src/views/hotel-view/HotelView.tsx +++ b/src/views/hotel-view/HotelView.tsx @@ -1,11 +1,10 @@ import { RoomSessionEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useState } from 'react'; import { GetConfiguration, GetConfigurationManager } from '../../api'; -import { useRoomSessionManagerEvent } from '../../hooks/events/nitro/session/room-session-manager-event'; -import { HotelViewProps } from './HotelView.types'; +import { UseRoomSessionManagerEvent } from '../../hooks'; import { WidgetSlotView } from './views/widget-slot/WidgetSlotView'; -export const HotelView: FC = props => +export const HotelView: FC<{}> = props => { const [isVisible, setIsVisible] = useState(true); const widgetSlotCount = 7; @@ -23,8 +22,8 @@ export const HotelView: FC = props => } }, []); - useRoomSessionManagerEvent(RoomSessionEvent.CREATED, onRoomSessionEvent); - useRoomSessionManagerEvent(RoomSessionEvent.ENDED, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionEvent.CREATED, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionEvent.ENDED, onRoomSessionEvent); if(!isVisible) return null; diff --git a/src/views/hotel-view/HotelView.types.ts b/src/views/hotel-view/HotelView.types.ts deleted file mode 100644 index d28f22f5..00000000 --- a/src/views/hotel-view/HotelView.types.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface HotelViewProps -{ - -} diff --git a/src/views/hotel-view/views/widgets/bonus-rare/BonusRareWidgetView.tsx b/src/views/hotel-view/views/widgets/bonus-rare/BonusRareWidgetView.tsx index a19a9cda..c97d2b84 100644 --- a/src/views/hotel-view/views/widgets/bonus-rare/BonusRareWidgetView.tsx +++ b/src/views/hotel-view/views/widgets/bonus-rare/BonusRareWidgetView.tsx @@ -1,6 +1,7 @@ import { BonusRareInfoMessageEvent, GetBonusRareInfoMessageComposer } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; -import { CreateMessageHook, SendMessageHook } from '../../../../../hooks/messages/message-event'; +import { SendMessageComposer } from '../../../../../api'; +import { UseMessageEventHook } from '../../../../../hooks'; import { BonusRareWidgetViewProps } from './BonusRareWidgetView.types'; export const BonusRareWidgetView: FC = props => @@ -20,11 +21,11 @@ export const BonusRareWidgetView: FC = props => setCoinsStillRequiredToBuy(parser.coinsStillRequiredToBuy); }, []); - CreateMessageHook(BonusRareInfoMessageEvent, onBonusRareInfoMessageEvent); + UseMessageEventHook(BonusRareInfoMessageEvent, onBonusRareInfoMessageEvent); useEffect(() => { - SendMessageHook(new GetBonusRareInfoMessageComposer()); + SendMessageComposer(new GetBonusRareInfoMessageComposer()); }, []); if(!productType) return null; diff --git a/src/views/hotel-view/views/widgets/hall-of-fame/HallOfFameWidgetView.tsx b/src/views/hotel-view/views/widgets/hall-of-fame/HallOfFameWidgetView.tsx index 2cbfdc8c..c86cabfa 100644 --- a/src/views/hotel-view/views/widgets/hall-of-fame/HallOfFameWidgetView.tsx +++ b/src/views/hotel-view/views/widgets/hall-of-fame/HallOfFameWidgetView.tsx @@ -1,6 +1,7 @@ import { CommunityGoalHallOfFameData, CommunityGoalHallOfFameMessageEvent, GetCommunityGoalHallOfFameMessageComposer } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; -import { CreateMessageHook, SendMessageHook } from '../../../../../hooks/messages/message-event'; +import { SendMessageComposer } from '../../../../../api'; +import { UseMessageEventHook } from '../../../../../hooks'; import { HallOfFameItemView } from '../hall-of-fame-item/HallOfFameItemView'; import { HallOfFameWidgetViewProps } from './HallOfFameWidgetView.types'; @@ -16,11 +17,11 @@ export const HallOfFameWidgetView: FC = props => setData(parser.data); }, []); - CreateMessageHook(CommunityGoalHallOfFameMessageEvent, onCommunityGoalHallOfFameMessageEvent); + UseMessageEventHook(CommunityGoalHallOfFameMessageEvent, onCommunityGoalHallOfFameMessageEvent); useEffect(() => { - SendMessageHook(new GetCommunityGoalHallOfFameMessageComposer(conf)); + SendMessageComposer(new GetCommunityGoalHallOfFameMessageComposer(conf)); }, [ conf ]); if(!data) return null; diff --git a/src/views/hotel-view/views/widgets/promo-article/PromoArticleWidgetView.tsx b/src/views/hotel-view/views/widgets/promo-article/PromoArticleWidgetView.tsx index dfcf0fcf..f5af0982 100644 --- a/src/views/hotel-view/views/widgets/promo-article/PromoArticleWidgetView.tsx +++ b/src/views/hotel-view/views/widgets/promo-article/PromoArticleWidgetView.tsx @@ -1,7 +1,7 @@ import { GetPromoArticlesComposer, PromoArticleData, PromoArticlesMessageEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; -import { LocalizeText } from '../../../../../api'; -import { CreateMessageHook, SendMessageHook } from '../../../../../hooks'; +import { LocalizeText, SendMessageComposer } from '../../../../../api'; +import { UseMessageEventHook } from '../../../../../hooks'; import { PromoArticleWidgetViewProps } from './PromoArticleWidgetView.types'; export const PromoArticleWidgetView: FC = props => @@ -20,11 +20,11 @@ export const PromoArticleWidgetView: FC = props => setArticles(parser.articles); }, []); - CreateMessageHook(PromoArticlesMessageEvent, onPromoArticlesMessageEvent); + UseMessageEventHook(PromoArticlesMessageEvent, onPromoArticlesMessageEvent); useEffect(() => { - SendMessageHook(new GetPromoArticlesComposer()); + SendMessageComposer(new GetPromoArticlesComposer()); }, []); if(!articles) return null; diff --git a/src/views/notification-center/NotificationCenterMessageHandler.tsx b/src/views/notification-center/NotificationCenterMessageHandler.tsx index 2579d57e..35507f62 100644 --- a/src/views/notification-center/NotificationCenterMessageHandler.tsx +++ b/src/views/notification-center/NotificationCenterMessageHandler.tsx @@ -1,7 +1,7 @@ import { AchievementNotificationMessageEvent, ActivityPointNotificationMessageEvent, ClubGiftNotificationEvent, ClubGiftSelectedEvent, HabboBroadcastMessageEvent, HotelClosedAndOpensEvent, HotelClosesAndWillOpenAtEvent, HotelWillCloseInMinutesEvent, InfoFeedEnableMessageEvent, MaintenanceStatusMessageEvent, ModeratorCautionEvent, ModeratorMessageEvent, MOTDNotificationEvent, NotificationDialogMessageEvent, PetLevelNotificationEvent, PetReceivedMessageEvent, RespectReceivedEvent, RoomEnterEvent, UserBannedMessageEvent, Vector3d } from '@nitrots/nitro-renderer'; import { FC, useCallback } from 'react'; import { GetConfiguration, GetRoomEngine, GetSessionDataManager, LocalizeBadgeName, LocalizeText } from '../../api'; -import { CreateMessageHook } from '../../hooks/messages'; +import { UseMessageEventHook } from '../../hooks'; import { NotificationBubbleType } from './common/NotificationBubbleType'; import { NotificationUtilities } from './common/NotificationUtilities'; import { ProductImageUtility } from './common/ProductImageUtility'; @@ -22,7 +22,7 @@ export const NotificationCenterMessageHandler: FC { @@ -31,7 +31,7 @@ export const NotificationCenterMessageHandler: FC { @@ -45,7 +45,7 @@ export const NotificationCenterMessageHandler: FC { @@ -54,7 +54,7 @@ export const NotificationCenterMessageHandler: FC { @@ -63,7 +63,7 @@ export const NotificationCenterMessageHandler: FC { @@ -83,7 +83,7 @@ export const NotificationCenterMessageHandler: FC { @@ -92,7 +92,7 @@ export const NotificationCenterMessageHandler: FC { @@ -101,7 +101,7 @@ export const NotificationCenterMessageHandler: FC { @@ -118,7 +118,7 @@ export const NotificationCenterMessageHandler: FC { @@ -127,7 +127,7 @@ export const NotificationCenterMessageHandler: FC { @@ -136,7 +136,7 @@ export const NotificationCenterMessageHandler: FC { @@ -151,7 +151,7 @@ export const NotificationCenterMessageHandler: FC { @@ -160,7 +160,7 @@ export const NotificationCenterMessageHandler: FC { @@ -175,7 +175,7 @@ export const NotificationCenterMessageHandler: FC { @@ -184,7 +184,7 @@ export const NotificationCenterMessageHandler: FC { @@ -193,7 +193,7 @@ export const NotificationCenterMessageHandler: FC { @@ -202,7 +202,7 @@ export const NotificationCenterMessageHandler: FC { @@ -211,7 +211,7 @@ export const NotificationCenterMessageHandler: FC { @@ -220,7 +220,7 @@ export const NotificationCenterMessageHandler: FC = props => setAlerts(prevValue => [ alertItem, ...prevValue ]); }, []); - useUiEvent(NotificationAlertEvent.ALERT, onNotificationAlertEvent); + UseUiEvent(NotificationAlertEvent.ALERT, onNotificationAlertEvent); const onNotificationBubbleEvent = useCallback((event: NotificationBubbleEvent) => { @@ -34,7 +34,7 @@ export const NotificationCenterView: FC = props => setBubbleAlerts(prevValue => [ notificationItem, ...prevValue ]); }, []); - useUiEvent(NotificationBubbleEvent.NEW_BUBBLE, onNotificationBubbleEvent); + UseUiEvent(NotificationBubbleEvent.NEW_BUBBLE, onNotificationBubbleEvent); const onNotificationConfirmEvent = useCallback((event: NotificationConfirmEvent) => { @@ -43,7 +43,7 @@ export const NotificationCenterView: FC = props => setConfirms(prevValue => [ confirmItem, ...prevValue ]); }, []); - useUiEvent(NotificationConfirmEvent.CONFIRM, onNotificationConfirmEvent); + UseUiEvent(NotificationConfirmEvent.CONFIRM, onNotificationConfirmEvent); const closeAlert = useCallback((alert: NotificationAlertItem) => { diff --git a/src/views/notification-center/common/NotificationUtilities.ts b/src/views/notification-center/common/NotificationUtilities.ts index d751a68f..f7ecd990 100644 --- a/src/views/notification-center/common/NotificationUtilities.ts +++ b/src/views/notification-center/common/NotificationUtilities.ts @@ -3,7 +3,7 @@ import { CreateLinkEvent, GetConfiguration, GetNitroInstance, LocalizeText } fro import { CatalogPageName } from '../../../components/catalog/common/CatalogPageName'; import { NotificationAlertEvent, NotificationConfirmEvent } from '../../../events'; import { NotificationBubbleEvent } from '../../../events/notification-center/NotificationBubbleEvent'; -import { dispatchUiEvent } from '../../../hooks'; +import { DispatchUiEvent } from '../../../hooks'; import { NotificationAlertType } from './NotificationAlertType'; import { NotificationBubbleType } from './NotificationBubbleType'; @@ -93,7 +93,7 @@ export class NotificationUtilities { if(this.BUBBLES_DISABLED) return; - dispatchUiEvent(new NotificationBubbleEvent(message, type, imageUrl, internalLink)); + DispatchUiEvent(new NotificationBubbleEvent(message, type, imageUrl, internalLink)); } public static showClubGiftNotification(numGifts: number): void @@ -107,7 +107,7 @@ export class NotificationUtilities { messages = messages.map(message => this.cleanText(message)); - dispatchUiEvent(new NotificationAlertEvent(messages, NotificationAlertType.MOTD, null, null, LocalizeText('notifications.motd.title'))); + DispatchUiEvent(new NotificationAlertEvent(messages, NotificationAlertType.MOTD, null, null, LocalizeText('notifications.motd.title'))); } public static confirm(message: string, onConfirm: Function, onCancel: Function, confirmText: string = null, cancelText: string = null, title: string = null, type: string = null): void @@ -118,7 +118,7 @@ export class NotificationUtilities if(!title || !title.length) title = LocalizeText('notifications.broadcast.title'); - dispatchUiEvent(new NotificationConfirmEvent(type, this.cleanText(message), onConfirm, onCancel, confirmText, cancelText, title)); + DispatchUiEvent(new NotificationConfirmEvent(type, this.cleanText(message), onConfirm, onCancel, confirmText, cancelText, title)); } public static simpleAlert(message: string, type: string = null, clickUrl: string = null, clickUrlText: string = null, title: string = null, imageUrl: string = null): void @@ -127,7 +127,7 @@ export class NotificationUtilities if(!type || !type.length) type = NotificationAlertType.DEFAULT; - dispatchUiEvent(new NotificationAlertEvent([ this.cleanText(message) ], type, clickUrl, clickUrlText, title, imageUrl)); + DispatchUiEvent(new NotificationAlertEvent([ this.cleanText(message) ], type, clickUrl, clickUrlText, title, imageUrl)); } public static showModeratorMessage(message: string, url: string = null, showHabboWay: boolean = true): void diff --git a/src/views/room/RoomColorView.tsx b/src/views/room/RoomColorView.tsx index 107ab6fe..813fdee9 100644 --- a/src/views/room/RoomColorView.tsx +++ b/src/views/room/RoomColorView.tsx @@ -1,8 +1,7 @@ import { ColorConverter, NitroAdjustmentFilter, NitroContainer, NitroSprite, NitroTexture, RoomBackgroundColorEvent, RoomEngineDimmerStateEvent, RoomEngineEvent, RoomId, RoomObjectHSLColorEnabledEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useState } from 'react'; import { GetNitroInstance, GetRoomEngine, RoomWidgetUpdateBackgroundColorPreviewEvent, RoomWidgetUpdateRoomViewEvent } from '../../api'; -import { UseMountEffect } from '../../hooks'; -import { CreateEventDispatcherHook, useRoomEngineEvent } from '../../hooks/events'; +import { UseEventDispatcherHook, UseMountEffect, UseRoomEngineEvent } from '../../hooks'; import { useRoomContext } from './context/RoomContext'; export const RoomColorView: FC<{}> = props => @@ -143,16 +142,16 @@ export const RoomColorView: FC<{}> = props => } }, [ widgetHandler, updateRoomBackgroundColor, updateRoomFilterColor ]); - useRoomEngineEvent(RoomObjectHSLColorEnabledEvent.ROOM_BACKGROUND_COLOR, onRoomEngineEvent); - useRoomEngineEvent(RoomBackgroundColorEvent.ROOM_COLOR, onRoomEngineEvent); - useRoomEngineEvent(RoomEngineDimmerStateEvent.ROOM_COLOR, onRoomEngineEvent); + UseRoomEngineEvent(RoomObjectHSLColorEnabledEvent.ROOM_BACKGROUND_COLOR, onRoomEngineEvent); + UseRoomEngineEvent(RoomBackgroundColorEvent.ROOM_COLOR, onRoomEngineEvent); + UseRoomEngineEvent(RoomEngineDimmerStateEvent.ROOM_COLOR, onRoomEngineEvent); const onRoomWidgetUpdateRoomViewEvent = useCallback((event: RoomWidgetUpdateRoomViewEvent) => { updateRoomBackground(roomBackgroundColor); }, [ roomBackgroundColor, updateRoomBackground ]); - CreateEventDispatcherHook(RoomWidgetUpdateRoomViewEvent.SIZE_CHANGED, eventDispatcher, onRoomWidgetUpdateRoomViewEvent); + UseEventDispatcherHook(RoomWidgetUpdateRoomViewEvent.SIZE_CHANGED, eventDispatcher, onRoomWidgetUpdateRoomViewEvent); const onRoomWidgetUpdateBackgroundColorPreviewEvent = useCallback((event: RoomWidgetUpdateBackgroundColorPreviewEvent) => { @@ -172,8 +171,8 @@ export const RoomColorView: FC<{}> = props => } }, [ originalRoomBackgroundColor, updateRoomBackgroundColor, updateRoomBackground ]); - CreateEventDispatcherHook(RoomWidgetUpdateBackgroundColorPreviewEvent.PREVIEW, eventDispatcher, onRoomWidgetUpdateBackgroundColorPreviewEvent); - CreateEventDispatcherHook(RoomWidgetUpdateBackgroundColorPreviewEvent.CLEAR_PREVIEW, eventDispatcher, onRoomWidgetUpdateBackgroundColorPreviewEvent); + UseEventDispatcherHook(RoomWidgetUpdateBackgroundColorPreviewEvent.PREVIEW, eventDispatcher, onRoomWidgetUpdateBackgroundColorPreviewEvent); + UseEventDispatcherHook(RoomWidgetUpdateBackgroundColorPreviewEvent.CLEAR_PREVIEW, eventDispatcher, onRoomWidgetUpdateBackgroundColorPreviewEvent); UseMountEffect(updateRoomBackground); diff --git a/src/views/room/widgets/RoomWidgetsView.tsx b/src/views/room/widgets/RoomWidgetsView.tsx index d7694e38..dc00e81b 100644 --- a/src/views/room/widgets/RoomWidgetsView.tsx +++ b/src/views/room/widgets/RoomWidgetsView.tsx @@ -2,7 +2,7 @@ import { RoomEngineEvent, RoomEngineObjectEvent, RoomEngineRoomAdEvent, RoomEngi import { FC, useCallback } from 'react'; import { CanManipulateFurniture, GetRoomEngine, GetSessionDataManager, IsFurnitureSelectionDisabled, LocalizeText, ProcessRoomObjectOperation, RoomWidgetFurniToWidgetMessage, RoomWidgetUpdateRoomEngineEvent, RoomWidgetUpdateRoomObjectEvent } from '../../../api'; import { FriendRequestEvent } from '../../../events'; -import { useRoomEngineEvent, useRoomSessionManagerEvent, useUiEvent } from '../../../hooks'; +import { UseRoomEngineEvent, UseRoomSessionManagerEvent, UseUiEvent } from '../../../hooks'; import { NotificationAlertType } from '../../notification-center/common/NotificationAlertType'; import { NotificationUtilities } from '../../notification-center/common/NotificationUtilities'; import { useRoomContext } from '../context/RoomContext'; @@ -49,9 +49,9 @@ export const RoomWidgetsView: FC<{}> = props => } }, [ eventDispatcher ]); - useRoomEngineEvent(RoomEngineEvent.NORMAL_MODE, onRoomEngineEvent); - useRoomEngineEvent(RoomEngineEvent.GAME_MODE, onRoomEngineEvent); - useRoomEngineEvent(RoomZoomEvent.ROOM_ZOOM, onRoomEngineEvent); + UseRoomEngineEvent(RoomEngineEvent.NORMAL_MODE, onRoomEngineEvent); + UseRoomEngineEvent(RoomEngineEvent.GAME_MODE, onRoomEngineEvent); + UseRoomEngineEvent(RoomZoomEvent.ROOM_ZOOM, onRoomEngineEvent); const handleRoomAdClick = useCallback((event: RoomEngineRoomAdEvent) => { @@ -211,47 +211,47 @@ export const RoomWidgetsView: FC<{}> = props => } }, [ roomSession, widgetHandler, handleRoomAdClick, handleRoomAdTooltip ]); - useRoomEngineEvent(RoomEngineObjectEvent.SELECTED, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineObjectEvent.DESELECTED, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineObjectEvent.ADDED, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineObjectEvent.REMOVED, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineObjectEvent.PLACED, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineObjectEvent.REQUEST_MOVE, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineObjectEvent.REQUEST_ROTATE, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineObjectEvent.REQUEST_MANIPULATION, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineObjectEvent.MOUSE_ENTER, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineObjectEvent.MOUSE_LEAVE, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_CREDITFURNI, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_STICKIE, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_PRESENT, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_TROPHY, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_TEASER, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_ECOTRONBOX, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_DIMMER, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_PLACEHOLDER, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_CLOTHING_CHANGE, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_PLAYLIST_EDITOR, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_ACHIEVEMENT_RESOLUTION_ENGRAVING, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_BADGE_DISPLAY_ENGRAVING, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_ACHIEVEMENT_RESOLUTION_FAILED, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.OPEN_WIDGET, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.CLOSE_WIDGET, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.OPEN_FURNI_CONTEXT_MENU, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.CLOSE_FURNI_CONTEXT_MENU, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REMOVE_DIMMER, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_MANNEQUIN, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineUseProductEvent.USE_PRODUCT_FROM_INVENTORY, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineUseProductEvent.USE_PRODUCT_FROM_ROOM, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_BACKGROUND_COLOR, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_FRIEND_FURNITURE_ENGRAVING, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_HIGH_SCORE_DISPLAY, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_HIDE_HIGH_SCORE_DISPLAY, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_INTERNAL_LINK, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_ROOM_LINK, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineRoomAdEvent.FURNI_CLICK, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineRoomAdEvent.FURNI_DOUBLE_CLICK, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineRoomAdEvent.TOOLTIP_SHOW, onRoomEngineObjectEvent); - useRoomEngineEvent(RoomEngineRoomAdEvent.TOOLTIP_HIDE, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineObjectEvent.SELECTED, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineObjectEvent.DESELECTED, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineObjectEvent.ADDED, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineObjectEvent.REMOVED, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineObjectEvent.PLACED, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineObjectEvent.REQUEST_MOVE, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineObjectEvent.REQUEST_ROTATE, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineObjectEvent.REQUEST_MANIPULATION, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineObjectEvent.MOUSE_ENTER, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineObjectEvent.MOUSE_LEAVE, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_CREDITFURNI, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_STICKIE, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_PRESENT, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_TROPHY, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_TEASER, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_ECOTRONBOX, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_DIMMER, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_PLACEHOLDER, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_CLOTHING_CHANGE, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_PLAYLIST_EDITOR, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_ACHIEVEMENT_RESOLUTION_ENGRAVING, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_BADGE_DISPLAY_ENGRAVING, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_ACHIEVEMENT_RESOLUTION_FAILED, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.OPEN_WIDGET, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.CLOSE_WIDGET, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.OPEN_FURNI_CONTEXT_MENU, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.CLOSE_FURNI_CONTEXT_MENU, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REMOVE_DIMMER, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_MANNEQUIN, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineUseProductEvent.USE_PRODUCT_FROM_INVENTORY, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineUseProductEvent.USE_PRODUCT_FROM_ROOM, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_BACKGROUND_COLOR, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_FRIEND_FURNITURE_ENGRAVING, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_HIGH_SCORE_DISPLAY, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_HIDE_HIGH_SCORE_DISPLAY, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_INTERNAL_LINK, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_ROOM_LINK, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineRoomAdEvent.FURNI_CLICK, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineRoomAdEvent.FURNI_DOUBLE_CLICK, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineRoomAdEvent.TOOLTIP_SHOW, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineRoomAdEvent.TOOLTIP_HIDE, onRoomEngineObjectEvent); const onRoomSessionEvent = useCallback((event: RoomSessionEvent) => { @@ -260,27 +260,27 @@ export const RoomWidgetsView: FC<{}> = props => widgetHandler.processEvent(event); }, [ widgetHandler ]); - useRoomSessionManagerEvent(RoomSessionChatEvent.CHAT_EVENT, onRoomSessionEvent); - useRoomSessionManagerEvent(RoomSessionChatEvent.FLOOD_EVENT, onRoomSessionEvent); - useRoomSessionManagerEvent(RoomSessionDanceEvent.RSDE_DANCE, onRoomSessionEvent); - useRoomSessionManagerEvent(RoomSessionUserBadgesEvent.RSUBE_BADGES, onRoomSessionEvent); - useRoomSessionManagerEvent(RoomSessionUserFigureUpdateEvent.USER_FIGURE, onRoomSessionEvent); - useRoomSessionManagerEvent(RoomSessionPetStatusUpdateEvent.PET_STATUS_UPDATE, onRoomSessionEvent); - useRoomSessionManagerEvent(RoomSessionDoorbellEvent.DOORBELL, onRoomSessionEvent); - useRoomSessionManagerEvent(RoomSessionDoorbellEvent.RSDE_REJECTED, onRoomSessionEvent); - useRoomSessionManagerEvent(RoomSessionDoorbellEvent.RSDE_ACCEPTED, onRoomSessionEvent); - useRoomSessionManagerEvent(RoomSessionDimmerPresetsEvent.ROOM_DIMMER_PRESETS, onRoomSessionEvent); - useRoomSessionManagerEvent(RoomSessionFriendRequestEvent.RSFRE_FRIEND_REQUEST, onRoomSessionEvent); - useRoomSessionManagerEvent(RoomSessionPresentEvent.RSPE_PRESENT_OPENED, onRoomSessionEvent); - useRoomSessionManagerEvent(RoomSessionPetInfoUpdateEvent.PET_INFO, onRoomSessionEvent); - useRoomSessionManagerEvent(RoomSessionWordQuizEvent.ANSWERED, onRoomSessionEvent); - useRoomSessionManagerEvent(RoomSessionWordQuizEvent.FINISHED, onRoomSessionEvent); - useRoomSessionManagerEvent(RoomSessionWordQuizEvent.QUESTION, onRoomSessionEvent); - useRoomSessionManagerEvent(RoomSessionPollEvent.OFFER, onRoomSessionEvent); - useRoomSessionManagerEvent(RoomSessionPollEvent.ERROR, onRoomSessionEvent); - useRoomSessionManagerEvent(RoomSessionPollEvent.CONTENT, onRoomSessionEvent); - useUiEvent(FriendRequestEvent.ACCEPTED, onRoomSessionEvent); - useUiEvent(FriendRequestEvent.DECLINED, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionChatEvent.CHAT_EVENT, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionChatEvent.FLOOD_EVENT, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionDanceEvent.RSDE_DANCE, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionUserBadgesEvent.RSUBE_BADGES, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionUserFigureUpdateEvent.USER_FIGURE, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionPetStatusUpdateEvent.PET_STATUS_UPDATE, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionDoorbellEvent.DOORBELL, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionDoorbellEvent.RSDE_REJECTED, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionDoorbellEvent.RSDE_ACCEPTED, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionDimmerPresetsEvent.ROOM_DIMMER_PRESETS, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionFriendRequestEvent.RSFRE_FRIEND_REQUEST, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionPresentEvent.RSPE_PRESENT_OPENED, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionPetInfoUpdateEvent.PET_INFO, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionWordQuizEvent.ANSWERED, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionWordQuizEvent.FINISHED, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionWordQuizEvent.QUESTION, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionPollEvent.OFFER, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionPollEvent.ERROR, onRoomSessionEvent); + UseRoomSessionManagerEvent(RoomSessionPollEvent.CONTENT, onRoomSessionEvent); + UseUiEvent(FriendRequestEvent.ACCEPTED, onRoomSessionEvent); + UseUiEvent(FriendRequestEvent.DECLINED, onRoomSessionEvent); const onRoomSessionErrorMessageEvent = useCallback((event: RoomSessionErrorMessageEvent) => { @@ -335,18 +335,18 @@ export const RoomWidgetsView: FC<{}> = props => NotificationUtilities.simpleAlert(errorMessage, NotificationAlertType.DEFAULT, null, null, errorTitle); }, []); - useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_KICKED, onRoomSessionErrorMessageEvent); - useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_PETS_FORBIDDEN_IN_HOTEL, onRoomSessionErrorMessageEvent); - useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_PETS_FORBIDDEN_IN_FLAT, onRoomSessionErrorMessageEvent); - useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_MAX_PETS, onRoomSessionErrorMessageEvent); - useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_MAX_NUMBER_OF_OWN_PETS, onRoomSessionErrorMessageEvent); - useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_NO_FREE_TILES_FOR_PET, onRoomSessionErrorMessageEvent); - useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_SELECTED_TILE_NOT_FREE_FOR_PET, onRoomSessionErrorMessageEvent); - useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_BOTS_FORBIDDEN_IN_HOTEL, onRoomSessionErrorMessageEvent); - useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_BOTS_FORBIDDEN_IN_FLAT, onRoomSessionErrorMessageEvent); - useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_BOT_LIMIT_REACHED, onRoomSessionErrorMessageEvent); - useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_SELECTED_TILE_NOT_FREE_FOR_BOT, onRoomSessionErrorMessageEvent); - useRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_BOT_NAME_NOT_ACCEPTED, onRoomSessionErrorMessageEvent); + UseRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_KICKED, onRoomSessionErrorMessageEvent); + UseRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_PETS_FORBIDDEN_IN_HOTEL, onRoomSessionErrorMessageEvent); + UseRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_PETS_FORBIDDEN_IN_FLAT, onRoomSessionErrorMessageEvent); + UseRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_MAX_PETS, onRoomSessionErrorMessageEvent); + UseRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_MAX_NUMBER_OF_OWN_PETS, onRoomSessionErrorMessageEvent); + UseRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_NO_FREE_TILES_FOR_PET, onRoomSessionErrorMessageEvent); + UseRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_SELECTED_TILE_NOT_FREE_FOR_PET, onRoomSessionErrorMessageEvent); + UseRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_BOTS_FORBIDDEN_IN_HOTEL, onRoomSessionErrorMessageEvent); + UseRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_BOTS_FORBIDDEN_IN_FLAT, onRoomSessionErrorMessageEvent); + UseRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_BOT_LIMIT_REACHED, onRoomSessionErrorMessageEvent); + UseRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_SELECTED_TILE_NOT_FREE_FOR_BOT, onRoomSessionErrorMessageEvent); + UseRoomSessionManagerEvent(RoomSessionErrorMessageEvent.RSEME_BOT_NAME_NOT_ACCEPTED, onRoomSessionErrorMessageEvent); if(!widgetHandler) return null; diff --git a/src/views/room/widgets/avatar-info/AvatarInfoRentableBotChatView.tsx b/src/views/room/widgets/avatar-info/AvatarInfoRentableBotChatView.tsx index f3f4680d..6c96d635 100644 --- a/src/views/room/widgets/avatar-info/AvatarInfoRentableBotChatView.tsx +++ b/src/views/room/widgets/avatar-info/AvatarInfoRentableBotChatView.tsx @@ -1,8 +1,7 @@ import { BotSkillSaveComposer } from '@nitrots/nitro-renderer'; import { FC, useMemo, useState } from 'react'; -import { GetRoomObjectBounds, GetRoomSession, LocalizeText, RoomWidgetUpdateRentableBotChatEvent } from '../../../../api'; +import { GetRoomObjectBounds, GetRoomSession, LocalizeText, RoomWidgetUpdateRentableBotChatEvent, SendMessageComposer } from '../../../../api'; import { Base, Button, Column, DraggableWindow, DraggableWindowPosition, Flex, Text } from '../../../../common'; -import { SendMessageHook } from '../../../../hooks'; import { ContextMenuHeaderView } from '../context-menu/ContextMenuHeaderView'; import { BotSkillsEnum } from './common/BotSkillsEnum'; @@ -29,7 +28,7 @@ export const AvatarInfoRentableBotChatView: FC SendMessageHook(new RequestBotCommandConfigurationComposer(rentableBotData.webID, skillType)); + const requestBotCommandConfiguration = (skillType: number) => SendMessageComposer(new RequestBotCommandConfigurationComposer(rentableBotData.webID, skillType)); const processAction = (name: string) => { @@ -80,45 +80,45 @@ export const AvatarInfoWidgetRentableBotView: FC = props => } }, [ isGameMode ]); - CreateEventDispatcherHook(RoomWidgetUpdateRoomEngineEvent.NORMAL_MODE, eventDispatcher, onRoomWidgetRoomEngineUpdateEvent); - CreateEventDispatcherHook(RoomWidgetUpdateRoomEngineEvent.GAME_MODE, eventDispatcher, onRoomWidgetRoomEngineUpdateEvent); + UseEventDispatcherHook(RoomWidgetUpdateRoomEngineEvent.NORMAL_MODE, eventDispatcher, onRoomWidgetRoomEngineUpdateEvent); + UseEventDispatcherHook(RoomWidgetUpdateRoomEngineEvent.GAME_MODE, eventDispatcher, onRoomWidgetRoomEngineUpdateEvent); const onRoomObjectRemoved = useCallback((event: RoomWidgetUpdateRoomObjectEvent) => { @@ -152,8 +152,8 @@ export const AvatarInfoWidgetView: FC<{}> = props => } }, [ name, infoStandEvent, nameBubbles, productBubbles, removeNameBubble, clearInfoStandEvent ]); - CreateEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.USER_REMOVED, eventDispatcher, onRoomObjectRemoved); - CreateEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.FURNI_REMOVED, eventDispatcher, onRoomObjectRemoved); + UseEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.USER_REMOVED, eventDispatcher, onRoomObjectRemoved); + UseEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.FURNI_REMOVED, eventDispatcher, onRoomObjectRemoved); const onObjectRolled = useCallback((event: RoomWidgetUpdateRoomObjectEvent) => { @@ -180,8 +180,8 @@ export const AvatarInfoWidgetView: FC<{}> = props => } }, [ infoStandEvent, name, widgetHandler ]); - CreateEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.OBJECT_ROLL_OVER, eventDispatcher, onObjectRolled); - CreateEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.OBJECT_ROLL_OUT, eventDispatcher, onObjectRolled); + UseEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.OBJECT_ROLL_OVER, eventDispatcher, onObjectRolled); + UseEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.OBJECT_ROLL_OUT, eventDispatcher, onObjectRolled); const onObjectDeselected = useCallback((event: RoomWidgetUpdateRoomObjectEvent) => { @@ -189,7 +189,7 @@ export const AvatarInfoWidgetView: FC<{}> = props => if(productBubbles.length) setProductBubbles([]); }, [ infoStandEvent, productBubbles, clearInfoStandEvent ]); - CreateEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.OBJECT_DESELECTED, eventDispatcher, onObjectDeselected); + UseEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.OBJECT_DESELECTED, eventDispatcher, onObjectDeselected); const onRoomWidgetObjectNameEvent = useCallback((event: RoomWidgetObjectNameEvent) => { @@ -199,7 +199,7 @@ export const AvatarInfoWidgetView: FC<{}> = props => clearProductBubbles(); }, [ clearProductBubbles ]); - CreateEventDispatcherHook(RoomWidgetObjectNameEvent.TYPE, eventDispatcher, onRoomWidgetObjectNameEvent); + UseEventDispatcherHook(RoomWidgetObjectNameEvent.TYPE, eventDispatcher, onRoomWidgetObjectNameEvent); const onRoomWidgetUpdateInfostandEvent = useCallback((event: RoomWidgetUpdateInfostandEvent) => { @@ -211,26 +211,26 @@ export const AvatarInfoWidgetView: FC<{}> = props => clearProductBubbles(); }, [ name, clearInfoStandEvent, clearProductBubbles ]); - CreateEventDispatcherHook(RoomWidgetUpdateInfostandFurniEvent.FURNI, eventDispatcher, onRoomWidgetUpdateInfostandEvent); - CreateEventDispatcherHook(RoomWidgetUpdateInfostandUserEvent.OWN_USER, eventDispatcher, onRoomWidgetUpdateInfostandEvent); - CreateEventDispatcherHook(RoomWidgetUpdateInfostandUserEvent.PEER, eventDispatcher, onRoomWidgetUpdateInfostandEvent); - CreateEventDispatcherHook(RoomWidgetUpdateInfostandUserEvent.BOT, eventDispatcher, onRoomWidgetUpdateInfostandEvent); - CreateEventDispatcherHook(RoomWidgetUpdateInfostandRentableBotEvent.RENTABLE_BOT, eventDispatcher, onRoomWidgetUpdateInfostandEvent); - CreateEventDispatcherHook(RoomWidgetUpdateInfostandPetEvent.PET_INFO, eventDispatcher, onRoomWidgetUpdateInfostandEvent); + UseEventDispatcherHook(RoomWidgetUpdateInfostandFurniEvent.FURNI, eventDispatcher, onRoomWidgetUpdateInfostandEvent); + UseEventDispatcherHook(RoomWidgetUpdateInfostandUserEvent.OWN_USER, eventDispatcher, onRoomWidgetUpdateInfostandEvent); + UseEventDispatcherHook(RoomWidgetUpdateInfostandUserEvent.PEER, eventDispatcher, onRoomWidgetUpdateInfostandEvent); + UseEventDispatcherHook(RoomWidgetUpdateInfostandUserEvent.BOT, eventDispatcher, onRoomWidgetUpdateInfostandEvent); + UseEventDispatcherHook(RoomWidgetUpdateInfostandRentableBotEvent.RENTABLE_BOT, eventDispatcher, onRoomWidgetUpdateInfostandEvent); + UseEventDispatcherHook(RoomWidgetUpdateInfostandPetEvent.PET_INFO, eventDispatcher, onRoomWidgetUpdateInfostandEvent); const onRoomWidgetUpdateDanceStatusEvent = useCallback((event: RoomWidgetUpdateDanceStatusEvent) => { setIsDancing(event.isDancing); }, []); - CreateEventDispatcherHook(RoomWidgetUpdateDanceStatusEvent.UPDATE_DANCE, eventDispatcher, onRoomWidgetUpdateDanceStatusEvent); + UseEventDispatcherHook(RoomWidgetUpdateDanceStatusEvent.UPDATE_DANCE, eventDispatcher, onRoomWidgetUpdateDanceStatusEvent); const onRoomWidgetUpdateRentableBotChatEvent = useCallback((event: RoomWidgetUpdateRentableBotChatEvent) => { setRentableBotChatEvent(event); }, []); - CreateEventDispatcherHook(RoomWidgetUpdateRentableBotChatEvent.UPDATE_CHAT, eventDispatcher, onRoomWidgetUpdateRentableBotChatEvent); + UseEventDispatcherHook(RoomWidgetUpdateRentableBotChatEvent.UPDATE_CHAT, eventDispatcher, onRoomWidgetUpdateRentableBotChatEvent); const onRoomWidgetUseProductBubbleEvent = useCallback((event: RoomWidgetUseProductBubbleEvent) => { @@ -252,7 +252,7 @@ export const AvatarInfoWidgetView: FC<{}> = props => }); }, []); - CreateEventDispatcherHook(RoomWidgetUseProductBubbleEvent.USE_PRODUCT_BUBBLES, eventDispatcher, onRoomWidgetUseProductBubbleEvent); + UseEventDispatcherHook(RoomWidgetUseProductBubbleEvent.USE_PRODUCT_BUBBLES, eventDispatcher, onRoomWidgetUseProductBubbleEvent); // const onFriendEnteredRoomEvent = useCallback((event: FriendEnteredRoomEvent) => // { @@ -269,7 +269,7 @@ export const AvatarInfoWidgetView: FC<{}> = props => setIsDecorating(event.isDecorating); }, []); - CreateEventDispatcherHook(RoomWidgetUpdateDecorateModeEvent.UPDATE_DECORATE, eventDispatcher, onRoomWidgetUpdateDecorateModeEvent); + UseEventDispatcherHook(RoomWidgetUpdateDecorateModeEvent.UPDATE_DECORATE, eventDispatcher, onRoomWidgetUpdateDecorateModeEvent); const decorateView = useMemo(() => { diff --git a/src/views/room/widgets/chat-input/ChatInputView.tsx b/src/views/room/widgets/chat-input/ChatInputView.tsx index 063231f7..fcffea67 100644 --- a/src/views/room/widgets/chat-input/ChatInputView.tsx +++ b/src/views/room/widgets/chat-input/ChatInputView.tsx @@ -2,7 +2,7 @@ import { HabboClubLevelEnum, RoomControllerLevel } from '@nitrots/nitro-renderer import { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { createPortal } from 'react-dom'; import { GetConfiguration, GetSessionDataManager, LocalizeText, RoomWidgetChatMessage, RoomWidgetChatTypingMessage, RoomWidgetUpdateChatInputContentEvent, RoomWidgetUpdateInfostandUserEvent, RoomWidgetUpdateRoomObjectEvent } from '../../../../api'; -import { CreateEventDispatcherHook } from '../../../../hooks/events'; +import { UseEventDispatcherHook } from '../../../../hooks'; import { useRoomContext } from '../../context/RoomContext'; import { ChatInputStyleSelectorView } from './ChatInputStyleSelectorView'; @@ -181,14 +181,14 @@ export const ChatInputView: FC<{}> = props => setSelectedUsername(''); }, []); - CreateEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.OBJECT_DESELECTED, eventDispatcher, onRoomWidgetRoomObjectUpdateEvent); + UseEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.OBJECT_DESELECTED, eventDispatcher, onRoomWidgetRoomObjectUpdateEvent); const onRoomWidgetUpdateInfostandUserEvent = useCallback((event: RoomWidgetUpdateInfostandUserEvent) => { setSelectedUsername(event.name); }, []); - CreateEventDispatcherHook(RoomWidgetUpdateInfostandUserEvent.PEER, eventDispatcher, onRoomWidgetUpdateInfostandUserEvent); + UseEventDispatcherHook(RoomWidgetUpdateInfostandUserEvent.PEER, eventDispatcher, onRoomWidgetUpdateInfostandUserEvent); const onRoomWidgetChatInputContentUpdateEvent = useCallback((event: RoomWidgetUpdateChatInputContentEvent) => { @@ -203,7 +203,7 @@ export const ChatInputView: FC<{}> = props => } }, [ chatModeIdWhisper ]); - CreateEventDispatcherHook(RoomWidgetUpdateChatInputContentEvent.CHAT_INPUT_CONTENT, eventDispatcher, onRoomWidgetChatInputContentUpdateEvent); + UseEventDispatcherHook(RoomWidgetUpdateChatInputContentEvent.CHAT_INPUT_CONTENT, eventDispatcher, onRoomWidgetChatInputContentUpdateEvent); const selectChatStyleId = useCallback((styleId: number) => { diff --git a/src/views/room/widgets/chat/ChatWidgetView.tsx b/src/views/room/widgets/chat/ChatWidgetView.tsx index 9181ffa3..e56d8f66 100644 --- a/src/views/room/widgets/chat/ChatWidgetView.tsx +++ b/src/views/room/widgets/chat/ChatWidgetView.tsx @@ -1,7 +1,7 @@ import { NitroPoint, RoomDragEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useRef, useState } from 'react'; import { RoomWidgetChatSelectAvatarMessage, RoomWidgetRoomObjectMessage, RoomWidgetUpdateChatEvent } from '../../../../api'; -import { CreateEventDispatcherHook, useRoomEngineEvent } from '../../../../hooks/events'; +import { UseEventDispatcherHook, UseRoomEngineEvent } from '../../../../hooks'; import { useRoomContext } from '../../context/RoomContext'; import { ChatWidgetMessageView } from './ChatWidgetMessageView'; import { ChatBubbleMessage } from './common/ChatBubbleMessage'; @@ -73,7 +73,7 @@ export const ChatWidgetView: FC<{}> = props => addChat(chatMessage); }, [ addChat ]); - CreateEventDispatcherHook(RoomWidgetUpdateChatEvent.CHAT_EVENT, eventDispatcher, onRoomWidgetUpdateChatEvent); + UseEventDispatcherHook(RoomWidgetUpdateChatEvent.CHAT_EVENT, eventDispatcher, onRoomWidgetUpdateChatEvent); const onRoomDragEvent = useCallback((event: RoomDragEvent) => { @@ -89,7 +89,7 @@ export const ChatWidgetView: FC<{}> = props => }); }, [ roomSession, chatMessages ]); - useRoomEngineEvent(RoomDragEvent.ROOM_DRAG, onRoomDragEvent); + UseRoomEngineEvent(RoomDragEvent.ROOM_DRAG, onRoomDragEvent); const onChatClicked = useCallback((chat: ChatBubbleMessage) => { diff --git a/src/views/room/widgets/choosers/FurniChooserWidgetView.tsx b/src/views/room/widgets/choosers/FurniChooserWidgetView.tsx index 99198b1d..5a0b876c 100644 --- a/src/views/room/widgets/choosers/FurniChooserWidgetView.tsx +++ b/src/views/room/widgets/choosers/FurniChooserWidgetView.tsx @@ -1,6 +1,6 @@ import { FC, useCallback, useState } from 'react'; import { LocalizeText, RoomObjectItem, RoomWidgetChooserContentEvent, RoomWidgetRequestWidgetMessage, RoomWidgetUpdateRoomObjectEvent } from '../../../../api'; -import { BatchUpdates, CreateEventDispatcherHook } from '../../../../hooks'; +import { BatchUpdates, UseEventDispatcherHook } from '../../../../hooks'; import { useRoomContext } from '../../context/RoomContext'; import { ChooserWidgetView } from './ChooserWidgetView'; @@ -32,7 +32,7 @@ export const FurniChooserWidgetView: FC<{}> = props => }); }, []); - CreateEventDispatcherHook(RoomWidgetChooserContentEvent.FURNI_CHOOSER_CONTENT, eventDispatcher, onRoomWidgetChooserContentEvent); + UseEventDispatcherHook(RoomWidgetChooserContentEvent.FURNI_CHOOSER_CONTENT, eventDispatcher, onRoomWidgetChooserContentEvent); const onRoomWidgetRoomObjectUpdateEvent = useCallback((event: RoomWidgetUpdateRoomObjectEvent) => { @@ -47,8 +47,8 @@ export const FurniChooserWidgetView: FC<{}> = props => } }, [ isVisible, refreshChooser ]); - CreateEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.FURNI_ADDED, eventDispatcher, onRoomWidgetRoomObjectUpdateEvent); - CreateEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.FURNI_REMOVED, eventDispatcher, onRoomWidgetRoomObjectUpdateEvent); + UseEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.FURNI_ADDED, eventDispatcher, onRoomWidgetRoomObjectUpdateEvent); + UseEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.FURNI_REMOVED, eventDispatcher, onRoomWidgetRoomObjectUpdateEvent); const close = useCallback(() => { diff --git a/src/views/room/widgets/choosers/UserChooserWidgetView.tsx b/src/views/room/widgets/choosers/UserChooserWidgetView.tsx index 18dcbefd..ace2bb26 100644 --- a/src/views/room/widgets/choosers/UserChooserWidgetView.tsx +++ b/src/views/room/widgets/choosers/UserChooserWidgetView.tsx @@ -1,6 +1,6 @@ import { FC, useCallback, useState } from 'react'; import { LocalizeText, RoomObjectItem, RoomWidgetChooserContentEvent, RoomWidgetRequestWidgetMessage, RoomWidgetUpdateRoomObjectEvent } from '../../../../api'; -import { BatchUpdates, CreateEventDispatcherHook } from '../../../../hooks'; +import { BatchUpdates, UseEventDispatcherHook } from '../../../../hooks'; import { useRoomContext } from '../../context/RoomContext'; import { ChooserWidgetView } from './ChooserWidgetView'; @@ -32,7 +32,7 @@ export const UserChooserWidgetView: FC<{}> = props => }); }, []); - CreateEventDispatcherHook(RoomWidgetChooserContentEvent.USER_CHOOSER_CONTENT, eventDispatcher, onRoomWidgetChooserContentEvent); + UseEventDispatcherHook(RoomWidgetChooserContentEvent.USER_CHOOSER_CONTENT, eventDispatcher, onRoomWidgetChooserContentEvent); const onRoomWidgetRoomObjectUpdateEvent = useCallback((event: RoomWidgetUpdateRoomObjectEvent) => { @@ -47,8 +47,8 @@ export const UserChooserWidgetView: FC<{}> = props => } }, [ isVisible, refreshChooser ]); - CreateEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.USER_ADDED, eventDispatcher, onRoomWidgetRoomObjectUpdateEvent); - CreateEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.USER_REMOVED, eventDispatcher, onRoomWidgetRoomObjectUpdateEvent); + UseEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.USER_ADDED, eventDispatcher, onRoomWidgetRoomObjectUpdateEvent); + UseEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.USER_REMOVED, eventDispatcher, onRoomWidgetRoomObjectUpdateEvent); const close = useCallback(() => { diff --git a/src/views/room/widgets/doorbell/DoorbellWidgetView.tsx b/src/views/room/widgets/doorbell/DoorbellWidgetView.tsx index 0aafa903..9516f01d 100644 --- a/src/views/room/widgets/doorbell/DoorbellWidgetView.tsx +++ b/src/views/room/widgets/doorbell/DoorbellWidgetView.tsx @@ -1,7 +1,7 @@ import { FC, useCallback, useState } from 'react'; import { LocalizeText, RoomWidgetDoorbellEvent, RoomWidgetLetUserInMessage } from '../../../../api'; import { Base, Button, Column, Flex, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../common'; -import { BatchUpdates, CreateEventDispatcherHook } from '../../../../hooks'; +import { BatchUpdates, UseEventDispatcherHook } from '../../../../hooks'; import { useRoomContext } from '../../context/RoomContext'; export const DoorbellWidgetView: FC<{}> = props => @@ -50,9 +50,9 @@ export const DoorbellWidgetView: FC<{}> = props => } }, [ addUser, removeUser ]); - CreateEventDispatcherHook(RoomWidgetDoorbellEvent.RINGING, eventDispatcher, onRoomWidgetDoorbellEvent); - CreateEventDispatcherHook(RoomWidgetDoorbellEvent.REJECTED, eventDispatcher, onRoomWidgetDoorbellEvent); - CreateEventDispatcherHook(RoomWidgetDoorbellEvent.ACCEPTED, eventDispatcher, onRoomWidgetDoorbellEvent); + UseEventDispatcherHook(RoomWidgetDoorbellEvent.RINGING, eventDispatcher, onRoomWidgetDoorbellEvent); + UseEventDispatcherHook(RoomWidgetDoorbellEvent.REJECTED, eventDispatcher, onRoomWidgetDoorbellEvent); + UseEventDispatcherHook(RoomWidgetDoorbellEvent.ACCEPTED, eventDispatcher, onRoomWidgetDoorbellEvent); const answer = useCallback((userName: string, flag: boolean) => { diff --git a/src/views/room/widgets/friend-request/FriendRequestWidgetView.tsx b/src/views/room/widgets/friend-request/FriendRequestWidgetView.tsx index fa53b347..fa59e20a 100644 --- a/src/views/room/widgets/friend-request/FriendRequestWidgetView.tsx +++ b/src/views/room/widgets/friend-request/FriendRequestWidgetView.tsx @@ -1,6 +1,6 @@ import { FC, useCallback, useState } from 'react'; import { RoomWidgetUpdateFriendRequestEvent } from '../../../../api'; -import { CreateEventDispatcherHook } from '../../../../hooks'; +import { UseEventDispatcherHook } from '../../../../hooks'; import { useRoomContext } from '../../context/RoomContext'; import { FriendRequestDialogView } from './FriendRequestDialogView'; @@ -54,8 +54,8 @@ export const FriendRequestWidgetView: FC<{}> = props => } }, [ showFriendRequest, hideFriendRequest ]); - CreateEventDispatcherHook(RoomWidgetUpdateFriendRequestEvent.SHOW_FRIEND_REQUEST, eventDispatcher, onRoomWidgetUpdateFriendRequestEvent); - CreateEventDispatcherHook(RoomWidgetUpdateFriendRequestEvent.HIDE_FRIEND_REQUEST, eventDispatcher, onRoomWidgetUpdateFriendRequestEvent); + UseEventDispatcherHook(RoomWidgetUpdateFriendRequestEvent.SHOW_FRIEND_REQUEST, eventDispatcher, onRoomWidgetUpdateFriendRequestEvent); + UseEventDispatcherHook(RoomWidgetUpdateFriendRequestEvent.HIDE_FRIEND_REQUEST, eventDispatcher, onRoomWidgetUpdateFriendRequestEvent); if(!friendRequests.length) return null; diff --git a/src/views/room/widgets/furniture/background-color/FurnitureBackgroundColorView.tsx b/src/views/room/widgets/furniture/background-color/FurnitureBackgroundColorView.tsx index ab0f243c..e401b65d 100644 --- a/src/views/room/widgets/furniture/background-color/FurnitureBackgroundColorView.tsx +++ b/src/views/room/widgets/furniture/background-color/FurnitureBackgroundColorView.tsx @@ -1,9 +1,9 @@ import { ApplyTonerComposer, RoomControllerLevel, RoomEngineObjectEvent, RoomEngineTriggerWidgetEvent, RoomObjectVariable } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; import ReactSlider from 'react-slider'; -import { GetRoomEngine, GetSessionDataManager, LocalizeText, RoomWidgetUpdateBackgroundColorPreviewEvent, RoomWidgetUpdateRoomObjectEvent } from '../../../../../api'; +import { GetRoomEngine, GetSessionDataManager, LocalizeText, RoomWidgetUpdateBackgroundColorPreviewEvent, RoomWidgetUpdateRoomObjectEvent, SendMessageComposer } from '../../../../../api'; import { Button, Column, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../../../common'; -import { BatchUpdates, CreateEventDispatcherHook, SendMessageHook, useRoomEngineEvent } from '../../../../../hooks'; +import { BatchUpdates, UseEventDispatcherHook, UseRoomEngineEvent } from '../../../../../hooks'; import { useRoomContext } from '../../../context/RoomContext'; export const FurnitureBackgroundColorView: FC<{}> = props => @@ -59,15 +59,15 @@ export const FurnitureBackgroundColorView: FC<{}> = props => } }, [ objectId, canOpenBackgroundToner, close ]); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_BACKGROUND_COLOR, onRoomEngineObjectEvent); - CreateEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.FURNI_REMOVED, eventDispatcher, onRoomEngineObjectEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_BACKGROUND_COLOR, onRoomEngineObjectEvent); + UseEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.FURNI_REMOVED, eventDispatcher, onRoomEngineObjectEvent); const processAction = useCallback((name: string) => { switch(name) { case 'apply': - SendMessageHook(new ApplyTonerComposer(objectId, hue, saturation, lightness)); + SendMessageComposer(new ApplyTonerComposer(objectId, hue, saturation, lightness)); break; case 'toggle': roomSession.useMultistateItem(objectId); diff --git a/src/views/room/widgets/furniture/badge-display/FurnitureBadgeDisplayView.tsx b/src/views/room/widgets/furniture/badge-display/FurnitureBadgeDisplayView.tsx index 039b7297..0e83e21d 100644 --- a/src/views/room/widgets/furniture/badge-display/FurnitureBadgeDisplayView.tsx +++ b/src/views/room/widgets/furniture/badge-display/FurnitureBadgeDisplayView.tsx @@ -2,8 +2,7 @@ import { NitroEvent, RoomEngineTriggerWidgetEvent, StringDataType } from '@nitro import { FC, useCallback, useState } from 'react'; import { GetRoomEngine, LocalizeBadgeDescription, LocalizeBadgeName, RoomWidgetUpdateRoomObjectEvent } from '../../../../../api'; import { LayoutTrophyView } from '../../../../../common'; -import { CreateEventDispatcherHook } from '../../../../../hooks'; -import { useRoomEngineEvent } from '../../../../../hooks/events/nitro/room/room-engine-event'; +import { UseEventDispatcherHook, UseRoomEngineEvent } from '../../../../../hooks'; import { useRoomContext } from '../../../context/RoomContext'; import { FurnitureTrophyData } from '../trophy/FurnitureTrophyData'; @@ -50,9 +49,9 @@ export const FurnitureBadgeDisplayView: FC<{}> = props => } }, []); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_BADGE_DISPLAY_ENGRAVING, onNitroEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_ACHIEVEMENT_RESOLUTION_ENGRAVING, onNitroEvent); - CreateEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.FURNI_REMOVED, widgetHandler.eventDispatcher, onNitroEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_BADGE_DISPLAY_ENGRAVING, onNitroEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_ACHIEVEMENT_RESOLUTION_ENGRAVING, onNitroEvent); + UseEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.FURNI_REMOVED, widgetHandler.eventDispatcher, onNitroEvent); const processAction = useCallback((type: string, value: string = null) => { diff --git a/src/views/room/widgets/furniture/context-menu/FurnitureContextMenuView.tsx b/src/views/room/widgets/furniture/context-menu/FurnitureContextMenuView.tsx index 872460cd..2c0411d5 100644 --- a/src/views/room/widgets/furniture/context-menu/FurnitureContextMenuView.tsx +++ b/src/views/room/widgets/furniture/context-menu/FurnitureContextMenuView.tsx @@ -1,10 +1,7 @@ -import { ContextMenuEnum, GroupFurniContextMenuInfoMessageParser, RoomEngineTriggerWidgetEvent, RoomObjectCategory } from '@nitrots/nitro-renderer'; -import { GroupFurniContextMenuInfoMessageEvent } from '@nitrots/nitro-renderer/src/nitro/communication/messages/incoming/room/furniture/GroupFurniContextMenuInfoMessageEvent'; +import { ContextMenuEnum, GroupFurniContextMenuInfoMessageEvent, GroupFurniContextMenuInfoMessageParser, RoomEngineTriggerWidgetEvent, RoomObjectCategory } from '@nitrots/nitro-renderer'; import { FC, useCallback, useState } from 'react'; -import { GetGroupInformation, GetRoomEngine, IsOwnerOfFurniture, LocalizeText, RoomWidgetFurniActionMessage, TryVisitRoom } from '../../../../../api'; -import { TryJoinGroup } from '../../../../../api/groups/TryJoinGroup'; -import { BatchUpdates, CreateMessageHook } from '../../../../../hooks'; -import { useRoomEngineEvent } from '../../../../../hooks/events'; +import { GetGroupInformation, GetRoomEngine, IsOwnerOfFurniture, LocalizeText, RoomWidgetFurniActionMessage, TryJoinGroup, TryVisitRoom } from '../../../../../api'; +import { BatchUpdates, UseMessageEventHook, UseRoomEngineEvent } from '../../../../../hooks'; import { useRoomContext } from '../../../context/RoomContext'; import { ContextMenuHeaderView } from '../../context-menu/ContextMenuHeaderView'; import { ContextMenuListItemView } from '../../context-menu/ContextMenuListItemView'; @@ -118,11 +115,11 @@ export const FurnitureContextMenuView: FC<{}> = props => } }, [ roomSession, objectId, close ]); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.OPEN_FURNI_CONTEXT_MENU, onRoomEngineTriggerWidgetEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.CLOSE_FURNI_CONTEXT_MENU, onRoomEngineTriggerWidgetEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_MONSTERPLANT_SEED_PLANT_CONFIRMATION_DIALOG, onRoomEngineTriggerWidgetEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_PURCHASABLE_CLOTHING_CONFIRMATION_DIALOG, onRoomEngineTriggerWidgetEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_EFFECTBOX_OPEN_DIALOG, onRoomEngineTriggerWidgetEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.OPEN_FURNI_CONTEXT_MENU, onRoomEngineTriggerWidgetEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.CLOSE_FURNI_CONTEXT_MENU, onRoomEngineTriggerWidgetEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_MONSTERPLANT_SEED_PLANT_CONFIRMATION_DIALOG, onRoomEngineTriggerWidgetEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_PURCHASABLE_CLOTHING_CONFIRMATION_DIALOG, onRoomEngineTriggerWidgetEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_EFFECTBOX_OPEN_DIALOG, onRoomEngineTriggerWidgetEvent); const onGroupFurniContextMenuInfoMessageEvent = useCallback((event: GroupFurniContextMenuInfoMessageEvent) => { @@ -137,7 +134,7 @@ export const FurnitureContextMenuView: FC<{}> = props => }); }, []); - CreateMessageHook(GroupFurniContextMenuInfoMessageEvent, onGroupFurniContextMenuInfoMessageEvent); + UseMessageEventHook(GroupFurniContextMenuInfoMessageEvent, onGroupFurniContextMenuInfoMessageEvent); const processAction = (name: string) => { diff --git a/src/views/room/widgets/furniture/custom-stack-height/FurnitureCustomStackHeightView.tsx b/src/views/room/widgets/furniture/custom-stack-height/FurnitureCustomStackHeightView.tsx index 8c527e4e..a028dbb6 100644 --- a/src/views/room/widgets/furniture/custom-stack-height/FurnitureCustomStackHeightView.tsx +++ b/src/views/room/widgets/furniture/custom-stack-height/FurnitureCustomStackHeightView.tsx @@ -1,9 +1,9 @@ import { FurnitureStackHeightComposer, FurnitureStackHeightEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; import ReactSlider from 'react-slider'; -import { LocalizeText, RoomWidgetUpdateCustomStackHeightEvent } from '../../../../../api'; +import { LocalizeText, RoomWidgetUpdateCustomStackHeightEvent, SendMessageComposer } from '../../../../../api'; import { Button, Column, Flex, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../../../common'; -import { BatchUpdates, CreateEventDispatcherHook, CreateMessageHook, SendMessageHook } from '../../../../../hooks'; +import { BatchUpdates, UseEventDispatcherHook, UseMessageEventHook } from '../../../../../hooks'; import { useRoomContext } from '../../../context/RoomContext'; const MAX_HEIGHT: number = 40; @@ -51,7 +51,7 @@ export const FurnitureCustomStackHeightView: FC<{}> = props => } }, [ updateHeight ]); - CreateEventDispatcherHook(RoomWidgetUpdateCustomStackHeightEvent.UPDATE_CUSTOM_STACK_HEIGHT, eventDispatcher, onRoomWidgetUpdateCustomStackHeightEvent); + UseEventDispatcherHook(RoomWidgetUpdateCustomStackHeightEvent.UPDATE_CUSTOM_STACK_HEIGHT, eventDispatcher, onRoomWidgetUpdateCustomStackHeightEvent); const onFurnitureStackHeightEvent = useCallback((event: FurnitureStackHeightEvent) => { @@ -62,11 +62,11 @@ export const FurnitureCustomStackHeightView: FC<{}> = props => updateHeight(parser.height, true); }, [ objectId, updateHeight ]); - CreateMessageHook(FurnitureStackHeightEvent, onFurnitureStackHeightEvent); + UseMessageEventHook(FurnitureStackHeightEvent, onFurnitureStackHeightEvent); const sendUpdate = useCallback((height: number) => { - SendMessageHook(new FurnitureStackHeightComposer(objectId, ~~(height))); + SendMessageComposer(new FurnitureStackHeightComposer(objectId, ~~(height))); }, [ objectId ]); useEffect(() => diff --git a/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.tsx b/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.tsx index 9c873a61..d76b7f32 100644 --- a/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.tsx +++ b/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.tsx @@ -4,7 +4,7 @@ import { FC, useCallback, useEffect, useMemo, useState } from 'react'; import ReactSlider from 'react-slider'; import { ColorUtils, GetConfiguration, LocalizeText, RoomWidgetDimmerChangeStateMessage, RoomWidgetDimmerPreviewMessage, RoomWidgetDimmerSavePresetMessage, RoomWidgetUpdateDimmerEvent, RoomWidgetUpdateDimmerStateEvent } from '../../../../../api'; import { Base, Button, Column, Flex, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView, Text } from '../../../../../common'; -import { BatchUpdates, CreateEventDispatcherHook } from '../../../../../hooks'; +import { BatchUpdates, UseEventDispatcherHook } from '../../../../../hooks'; import { useRoomContext } from '../../../context/RoomContext'; import { DimmerFurnitureWidgetPresetItem } from './DimmerFurnitureWidgetPresetItem'; @@ -73,9 +73,9 @@ export const FurnitureDimmerView: FC<{}> = props => } }, [ dimmerState ]); - CreateEventDispatcherHook(RoomWidgetUpdateDimmerEvent.PRESETS, eventDispatcher, onNitroEvent); - CreateEventDispatcherHook(RoomWidgetUpdateDimmerEvent.HIDE, eventDispatcher, onNitroEvent); - CreateEventDispatcherHook(RoomWidgetUpdateDimmerStateEvent.DIMMER_STATE, eventDispatcher, onNitroEvent); + UseEventDispatcherHook(RoomWidgetUpdateDimmerEvent.PRESETS, eventDispatcher, onNitroEvent); + UseEventDispatcherHook(RoomWidgetUpdateDimmerEvent.HIDE, eventDispatcher, onNitroEvent); + UseEventDispatcherHook(RoomWidgetUpdateDimmerStateEvent.DIMMER_STATE, eventDispatcher, onNitroEvent); const selectPresetId = useCallback((id: number) => { diff --git a/src/views/room/widgets/furniture/exchange-credit/FurnitureExchangeCreditView.tsx b/src/views/room/widgets/furniture/exchange-credit/FurnitureExchangeCreditView.tsx index 59c7c1d9..91f31f46 100644 --- a/src/views/room/widgets/furniture/exchange-credit/FurnitureExchangeCreditView.tsx +++ b/src/views/room/widgets/furniture/exchange-credit/FurnitureExchangeCreditView.tsx @@ -1,7 +1,7 @@ import { FC, useCallback, useState } from 'react'; import { LocalizeText, RoomWidgetCreditFurniRedeemMessage, RoomWidgetUpdateCreditFurniEvent } from '../../../../../api'; import { Base, Button, Column, Flex, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../../../common'; -import { BatchUpdates, CreateEventDispatcherHook } from '../../../../../hooks'; +import { BatchUpdates, UseEventDispatcherHook } from '../../../../../hooks'; import { useRoomContext } from '../../../context/RoomContext'; export const FurnitureExchangeCreditView: FC<{}> = props => @@ -19,7 +19,7 @@ export const FurnitureExchangeCreditView: FC<{}> = props => }); }, []); - CreateEventDispatcherHook(RoomWidgetUpdateCreditFurniEvent.CREDIT_FURNI_UPDATE, eventDispatcher, onRoomWidgetUpdateCreditFurniEvent); + UseEventDispatcherHook(RoomWidgetUpdateCreditFurniEvent.CREDIT_FURNI_UPDATE, eventDispatcher, onRoomWidgetUpdateCreditFurniEvent); const close = () => { diff --git a/src/views/room/widgets/furniture/external-image/FurnitureExternalImageView.tsx b/src/views/room/widgets/furniture/external-image/FurnitureExternalImageView.tsx index 45614741..9c8fd159 100644 --- a/src/views/room/widgets/furniture/external-image/FurnitureExternalImageView.tsx +++ b/src/views/room/widgets/furniture/external-image/FurnitureExternalImageView.tsx @@ -1,7 +1,7 @@ import { FC, useCallback, useState } from 'react'; import { IPhotoData, LocalizeText, RoomWidgetUpdateExternalImageEvent } from '../../../../../api'; import { Flex, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../../../common'; -import { BatchUpdates, CreateEventDispatcherHook } from '../../../../../hooks'; +import { BatchUpdates, UseEventDispatcherHook } from '../../../../../hooks'; import { useRoomContext } from '../../../context/RoomContext'; export const FurnitureExternalImageView: FC<{}> = props => @@ -31,7 +31,7 @@ export const FurnitureExternalImageView: FC<{}> = props => } }, []); - CreateEventDispatcherHook(RoomWidgetUpdateExternalImageEvent.UPDATE_EXTERNAL_IMAGE, eventDispatcher, onRoomWidgetUpdateExternalImageEvent); + UseEventDispatcherHook(RoomWidgetUpdateExternalImageEvent.UPDATE_EXTERNAL_IMAGE, eventDispatcher, onRoomWidgetUpdateExternalImageEvent); if((objectId === -1) || !photoData) return null; diff --git a/src/views/room/widgets/furniture/friend-furni/FurnitureFriendFurniView.tsx b/src/views/room/widgets/furniture/friend-furni/FurnitureFriendFurniView.tsx index 1016bda0..cee423a1 100644 --- a/src/views/room/widgets/furniture/friend-furni/FurnitureFriendFurniView.tsx +++ b/src/views/room/widgets/furniture/friend-furni/FurnitureFriendFurniView.tsx @@ -2,7 +2,7 @@ import { FriendFurniConfirmLockMessageComposer, LoveLockFurniFinishedEvent, Love import { FC, useCallback, useState } from 'react'; import { GetRoomEngine, GetRoomSession, LocalizeText, RoomWidgetUpdateRoomObjectEvent } from '../../../../../api'; import { DraggableWindow, NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../../common'; -import { CreateEventDispatcherHook, CreateMessageHook, useRoomEngineEvent } from '../../../../../hooks'; +import { UseEventDispatcherHook, UseMessageEventHook, UseRoomEngineEvent } from '../../../../../hooks'; import { AvatarImageView } from '../../../../shared/avatar-image/AvatarImageView'; import { useRoomContext } from '../../../context/RoomContext'; import { FurnitureEngravingLockData } from './FriendFurniLockData'; @@ -49,8 +49,8 @@ export const FurnitureFriendFurniView: FC<{}> = props => } }; - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_FRIEND_FURNITURE_ENGRAVING, onNitroEvent); - CreateEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.FURNI_REMOVED, eventDispatcher, onNitroEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_FRIEND_FURNITURE_ENGRAVING, onNitroEvent); + UseEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.FURNI_REMOVED, eventDispatcher, onNitroEvent); const onLoveLockFurniStartEvent = useCallback((event: LoveLockFurniStartEvent) => { @@ -65,7 +65,7 @@ export const FurnitureFriendFurniView: FC<{}> = props => }, []); - CreateMessageHook(LoveLockFurniStartEvent, onLoveLockFurniStartEvent); + UseMessageEventHook(LoveLockFurniStartEvent, onLoveLockFurniStartEvent); const processAction = useCallback((type: string, value: string = null) => { @@ -93,8 +93,8 @@ export const FurnitureFriendFurniView: FC<{}> = props => processAction('close_request'); }, [ processAction ]); - CreateMessageHook(LoveLockFurniFinishedEvent, onLoveLockDoneEvent); - CreateMessageHook(LoveLockFurniFriendConfirmedEvent, onLoveLockDoneEvent); + UseMessageEventHook(LoveLockFurniFinishedEvent, onLoveLockDoneEvent); + UseMessageEventHook(LoveLockFurniFriendConfirmedEvent, onLoveLockDoneEvent); return ( <> diff --git a/src/views/room/widgets/furniture/gift-opening/FurnitureGiftOpeningView.tsx b/src/views/room/widgets/furniture/gift-opening/FurnitureGiftOpeningView.tsx index 28e68f2d..6a6c0669 100644 --- a/src/views/room/widgets/furniture/gift-opening/FurnitureGiftOpeningView.tsx +++ b/src/views/room/widgets/furniture/gift-opening/FurnitureGiftOpeningView.tsx @@ -4,7 +4,7 @@ import { CreateLinkEvent, GetRoomEngine, GetSessionDataManager, LocalizeText, Ro import { Button, Column, Flex, LayoutGiftTagView, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../../../common'; import { ProductTypeEnum } from '../../../../../components/catalog/common/ProductTypeEnum'; import { BatchUpdates } from '../../../../../hooks'; -import { CreateEventDispatcherHook } from '../../../../../hooks/events/event-dispatcher.base'; +import { UseEventDispatcherHook } from '../../../../../hooks/events/UseEventDispatcherHook'; import { useRoomContext } from '../../../context/RoomContext'; const FLOOR: string = 'floor'; @@ -122,13 +122,13 @@ export const FurnitureGiftOpeningView: FC<{}> = props => } }, [ openRequested, getGiftImageUrl ]); - CreateEventDispatcherHook(RoomWidgetUpdatePresentDataEvent.PACKAGEINFO, eventDispatcher, onRoomWidgetUpdatePresentDataEvent); - CreateEventDispatcherHook(RoomWidgetUpdatePresentDataEvent.CONTENTS, eventDispatcher, onRoomWidgetUpdatePresentDataEvent); - CreateEventDispatcherHook(RoomWidgetUpdatePresentDataEvent.CONTENTS_FLOOR, eventDispatcher, onRoomWidgetUpdatePresentDataEvent); - CreateEventDispatcherHook(RoomWidgetUpdatePresentDataEvent.CONTENTS_LANDSCAPE, eventDispatcher, onRoomWidgetUpdatePresentDataEvent); - CreateEventDispatcherHook(RoomWidgetUpdatePresentDataEvent.CONTENTS_WALLPAPER, eventDispatcher, onRoomWidgetUpdatePresentDataEvent); - CreateEventDispatcherHook(RoomWidgetUpdatePresentDataEvent.CONTENTS_CLUB, eventDispatcher, onRoomWidgetUpdatePresentDataEvent); - CreateEventDispatcherHook(RoomWidgetUpdatePresentDataEvent.CONTENTS_IMAGE, eventDispatcher, onRoomWidgetUpdatePresentDataEvent); + UseEventDispatcherHook(RoomWidgetUpdatePresentDataEvent.PACKAGEINFO, eventDispatcher, onRoomWidgetUpdatePresentDataEvent); + UseEventDispatcherHook(RoomWidgetUpdatePresentDataEvent.CONTENTS, eventDispatcher, onRoomWidgetUpdatePresentDataEvent); + UseEventDispatcherHook(RoomWidgetUpdatePresentDataEvent.CONTENTS_FLOOR, eventDispatcher, onRoomWidgetUpdatePresentDataEvent); + UseEventDispatcherHook(RoomWidgetUpdatePresentDataEvent.CONTENTS_LANDSCAPE, eventDispatcher, onRoomWidgetUpdatePresentDataEvent); + UseEventDispatcherHook(RoomWidgetUpdatePresentDataEvent.CONTENTS_WALLPAPER, eventDispatcher, onRoomWidgetUpdatePresentDataEvent); + UseEventDispatcherHook(RoomWidgetUpdatePresentDataEvent.CONTENTS_CLUB, eventDispatcher, onRoomWidgetUpdatePresentDataEvent); + UseEventDispatcherHook(RoomWidgetUpdatePresentDataEvent.CONTENTS_IMAGE, eventDispatcher, onRoomWidgetUpdatePresentDataEvent); const onRoomWidgetRoomObjectUpdateEvent = useCallback((event: RoomWidgetUpdateRoomObjectEvent) => { @@ -140,7 +140,7 @@ export const FurnitureGiftOpeningView: FC<{}> = props => } }, [ objectId, placedItemId, placedInRoom, clearGift ]); - CreateEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.FURNI_REMOVED, eventDispatcher, onRoomWidgetRoomObjectUpdateEvent); + UseEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.FURNI_REMOVED, eventDispatcher, onRoomWidgetRoomObjectUpdateEvent); const close = useCallback(() => { diff --git a/src/views/room/widgets/furniture/high-score/FurnitureHighScoreView.tsx b/src/views/room/widgets/furniture/high-score/FurnitureHighScoreView.tsx index bd18c6d9..25ce5d74 100644 --- a/src/views/room/widgets/furniture/high-score/FurnitureHighScoreView.tsx +++ b/src/views/room/widgets/furniture/high-score/FurnitureHighScoreView.tsx @@ -2,7 +2,7 @@ import { HighScoreDataType, ObjectDataFactory, RoomEngineTriggerWidgetEvent, Roo import { FC, useCallback, useState } from 'react'; import { GetRoomEngine, LocalizeText } from '../../../../../api'; import { Column, Flex, Text } from '../../../../../common'; -import { useRoomEngineEvent } from '../../../../../hooks'; +import { UseRoomEngineEvent } from '../../../../../hooks'; import { useRoomContext } from '../../../context/RoomContext'; import { ContextMenuHeaderView } from '../../context-menu/ContextMenuHeaderView'; import { ContextMenuListView } from '../../context-menu/ContextMenuListView'; @@ -50,8 +50,8 @@ export const FurnitureHighScoreView: FC<{}> = props => } }, [roomSession, objectId, close]); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_HIGH_SCORE_DISPLAY, onRoomEngineTriggerWidgetEvent); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_HIDE_HIGH_SCORE_DISPLAY, onRoomEngineTriggerWidgetEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_HIGH_SCORE_DISPLAY, onRoomEngineTriggerWidgetEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_HIDE_HIGH_SCORE_DISPLAY, onRoomEngineTriggerWidgetEvent); if((objectId === -1) || !stuffData) return null; diff --git a/src/views/room/widgets/furniture/manipulation-menu/FurnitureManipulationMenuView.tsx b/src/views/room/widgets/furniture/manipulation-menu/FurnitureManipulationMenuView.tsx index 6b0af8f1..58aacdf6 100644 --- a/src/views/room/widgets/furniture/manipulation-menu/FurnitureManipulationMenuView.tsx +++ b/src/views/room/widgets/furniture/manipulation-menu/FurnitureManipulationMenuView.tsx @@ -2,8 +2,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { RoomObjectOperationType } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; import { ProcessRoomObjectOperation, RoomWidgetUpdateDecorateModeEvent, RoomWidgetUpdateRoomObjectEvent } from '../../../../../api'; -import { BatchUpdates } from '../../../../../hooks'; -import { CreateEventDispatcherHook } from '../../../../../hooks/events/event-dispatcher.base'; +import { BatchUpdates, UseEventDispatcherHook } from '../../../../../hooks'; import { useRoomContext } from '../../../context/RoomContext'; import { ObjectLocationView } from '../../object-location/ObjectLocationView'; @@ -66,8 +65,8 @@ export const FurnitureManipulationMenuView: FC<{}> = props => } }, [ objectId ]); - CreateEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.OBJECT_REQUEST_MANIPULATION, eventDispatcher, onRoomWidgetRoomObjectUpdateEvent); - CreateEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.OBJECT_DESELECTED, eventDispatcher, onRoomWidgetRoomObjectUpdateEvent); + UseEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.OBJECT_REQUEST_MANIPULATION, eventDispatcher, onRoomWidgetRoomObjectUpdateEvent); + UseEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.OBJECT_DESELECTED, eventDispatcher, onRoomWidgetRoomObjectUpdateEvent); const onRoomWidgetUpdateDecorateModeEvent = useCallback((event: RoomWidgetUpdateDecorateModeEvent) => { @@ -83,7 +82,7 @@ export const FurnitureManipulationMenuView: FC<{}> = props => }); }, [ moveFurniture ]); - CreateEventDispatcherHook(RoomWidgetUpdateDecorateModeEvent.UPDATE_DECORATE, eventDispatcher, onRoomWidgetUpdateDecorateModeEvent); + UseEventDispatcherHook(RoomWidgetUpdateDecorateModeEvent.UPDATE_DECORATE, eventDispatcher, onRoomWidgetUpdateDecorateModeEvent); useEffect(() => { diff --git a/src/views/room/widgets/furniture/mannequin/FurnitureMannequinView.tsx b/src/views/room/widgets/furniture/mannequin/FurnitureMannequinView.tsx index 5dd2fa89..dae6b89a 100644 --- a/src/views/room/widgets/furniture/mannequin/FurnitureMannequinView.tsx +++ b/src/views/room/widgets/furniture/mannequin/FurnitureMannequinView.tsx @@ -1,8 +1,8 @@ import { AvatarFigurePartType, FurnitureMannequinSaveLookComposer, FurnitureMannequinSaveNameComposer, FurnitureMultiStateComposer, HabboClubLevelEnum, IAvatarFigureContainer, RoomControllerLevel } from '@nitrots/nitro-renderer'; import { FC, KeyboardEvent, useCallback, useEffect, useState } from 'react'; -import { GetAvatarRenderManager, GetSessionDataManager, LocalizeText, RoomWidgetUpdateMannequinEvent } from '../../../../../api'; +import { GetAvatarRenderManager, GetSessionDataManager, LocalizeText, RoomWidgetUpdateMannequinEvent, SendMessageComposer } from '../../../../../api'; import { Base, Button, Column, Flex, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../../../common'; -import { BatchUpdates, CreateEventDispatcherHook, SendMessageHook } from '../../../../../hooks'; +import { BatchUpdates, UseEventDispatcherHook } from '../../../../../hooks'; import { AvatarImageView } from '../../../../shared/avatar-image/AvatarImageView'; import { CurrencyIcon } from '../../../../shared/currency-icon/CurrencyIcon'; import { useRoomContext } from '../../../context/RoomContext'; @@ -74,7 +74,7 @@ export const FurnitureMannequinView: FC<{}> = props => }); }, [ roomSession ]); - CreateEventDispatcherHook(RoomWidgetUpdateMannequinEvent.MANNEQUIN_UPDATE, eventDispatcher, onRoomWidgetUpdateMannequinEvent); + UseEventDispatcherHook(RoomWidgetUpdateMannequinEvent.MANNEQUIN_UPDATE, eventDispatcher, onRoomWidgetUpdateMannequinEvent); const getMergedFigureContainer = (figure: string, targetFigure: string) => { @@ -108,13 +108,13 @@ export const FurnitureMannequinView: FC<{}> = props => switch(action) { case ACTION_SAVE: - SendMessageHook(new FurnitureMannequinSaveLookComposer(objectId)); + SendMessageComposer(new FurnitureMannequinSaveLookComposer(objectId)); break; case ACTION_WEAR: - SendMessageHook(new FurnitureMultiStateComposer(objectId)); + SendMessageComposer(new FurnitureMultiStateComposer(objectId)); break; case ACTION_SET_NAME: - SendMessageHook(new FurnitureMannequinSaveNameComposer(objectId, name)); + SendMessageComposer(new FurnitureMannequinSaveNameComposer(objectId, name)); return; } diff --git a/src/views/room/widgets/furniture/stickie/FurnitureStickieView.tsx b/src/views/room/widgets/furniture/stickie/FurnitureStickieView.tsx index ac7591fd..96c1c128 100644 --- a/src/views/room/widgets/furniture/stickie/FurnitureStickieView.tsx +++ b/src/views/room/widgets/furniture/stickie/FurnitureStickieView.tsx @@ -2,7 +2,7 @@ import { NitroEvent, RoomEngineTriggerWidgetEvent, RoomObjectVariable } from '@n import { FC, useCallback, useState } from 'react'; import { ColorUtils, GetRoomEngine, GetRoomSession, GetSessionDataManager, RoomWidgetUpdateRoomObjectEvent } from '../../../../../api'; import { DraggableWindow, DraggableWindowPosition } from '../../../../../common'; -import { CreateEventDispatcherHook, useRoomEngineEvent } from '../../../../../hooks'; +import { UseEventDispatcherHook, UseRoomEngineEvent } from '../../../../../hooks'; import { useRoomContext } from '../../../context/RoomContext'; import { FurnitureStickieData } from './FurnitureStickieData'; import { getStickieColorName, STICKIE_COLORS } from './FurnitureStickieUtils'; @@ -57,8 +57,8 @@ export const FurnitureStickieView: FC<{}> = props => } }, []); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_STICKIE, onNitroEvent); - CreateEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.FURNI_REMOVED, eventDispatcher, onNitroEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_STICKIE, onNitroEvent); + UseEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.FURNI_REMOVED, eventDispatcher, onNitroEvent); const processAction = useCallback((type: string, value: string = null) => { diff --git a/src/views/room/widgets/furniture/trophy/FurnitureTrophyView.tsx b/src/views/room/widgets/furniture/trophy/FurnitureTrophyView.tsx index 5575188e..0faf9e47 100644 --- a/src/views/room/widgets/furniture/trophy/FurnitureTrophyView.tsx +++ b/src/views/room/widgets/furniture/trophy/FurnitureTrophyView.tsx @@ -2,8 +2,7 @@ import { NitroEvent, RoomEngineTriggerWidgetEvent, RoomObjectVariable } from '@n import { FC, useCallback, useState } from 'react'; import { GetRoomEngine, RoomWidgetUpdateRoomObjectEvent } from '../../../../../api'; import { LayoutTrophyView } from '../../../../../common'; -import { CreateEventDispatcherHook } from '../../../../../hooks/events/event-dispatcher.base'; -import { useRoomEngineEvent } from '../../../../../hooks/events/nitro/room/room-engine-event'; +import { UseEventDispatcherHook, UseRoomEngineEvent } from '../../../../../hooks'; import { useRoomContext } from '../../../context/RoomContext'; import { FurnitureTrophyData } from './FurnitureTrophyData'; @@ -54,8 +53,8 @@ export const FurnitureTrophyView: FC<{}> = props => } }, []); - useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_TROPHY, onNitroEvent); - CreateEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.FURNI_REMOVED, widgetHandler.eventDispatcher, onNitroEvent); + UseRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_TROPHY, onNitroEvent); + UseEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.FURNI_REMOVED, widgetHandler.eventDispatcher, onNitroEvent); const processAction = useCallback((type: string, value: string = null) => { diff --git a/src/views/room/widgets/furniture/youtube-tv/FurnitureYoutubeDisplayView.tsx b/src/views/room/widgets/furniture/youtube-tv/FurnitureYoutubeDisplayView.tsx index f7b1c10b..6dd06b89 100644 --- a/src/views/room/widgets/furniture/youtube-tv/FurnitureYoutubeDisplayView.tsx +++ b/src/views/room/widgets/furniture/youtube-tv/FurnitureYoutubeDisplayView.tsx @@ -1,9 +1,9 @@ import { ControlYoutubeDisplayPlaybackMessageComposer, SetYoutubeDisplayPlaylistMessageComposer, YoutubeControlVideoMessageEvent, YoutubeDisplayPlaylist, YoutubeDisplayPlaylistsEvent, YoutubeDisplayVideoMessageEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useMemo, useState } from 'react'; import YouTube, { Options } from 'react-youtube'; -import { FurnitureYoutubeDisplayWidgetHandler, LocalizeText, RoomWidgetUpdateYoutubeDisplayEvent } from '../../../../../api'; +import { FurnitureYoutubeDisplayWidgetHandler, LocalizeText, RoomWidgetUpdateYoutubeDisplayEvent, SendMessageComposer } from '../../../../../api'; import { Grid, LayoutGridItem, NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../../common'; -import { BatchUpdates, CreateEventDispatcherHook, CreateMessageHook, SendMessageHook } from '../../../../../hooks'; +import { BatchUpdates, UseEventDispatcherHook, UseMessageEventHook } from '../../../../../hooks'; import { useRoomContext } from '../../../context/RoomContext'; import { YoutubeVideoPlaybackStateEnum } from './utils/YoutubeVideoPlaybackStateEnum'; @@ -43,7 +43,7 @@ export const FurnitureYoutubeDisplayView: FC<{}> = props => setCurrentVideoState(-1); }, []); - CreateEventDispatcherHook(RoomWidgetUpdateYoutubeDisplayEvent.UPDATE_YOUTUBE_DISPLAY, eventDispatcher, onRoomWidgetUpdateYoutubeDisplayEvent); + UseEventDispatcherHook(RoomWidgetUpdateYoutubeDisplayEvent.UPDATE_YOUTUBE_DISPLAY, eventDispatcher, onRoomWidgetUpdateYoutubeDisplayEvent); const onVideo = useCallback((event: YoutubeDisplayVideoMessageEvent) => { @@ -104,40 +104,40 @@ export const FurnitureYoutubeDisplayView: FC<{}> = props => } }, [objectId, player]); - CreateMessageHook(YoutubeDisplayVideoMessageEvent, onVideo); - CreateMessageHook(YoutubeDisplayPlaylistsEvent, onPlaylists); - CreateMessageHook(YoutubeControlVideoMessageEvent, onControlVideo); + UseMessageEventHook(YoutubeDisplayVideoMessageEvent, onVideo); + UseMessageEventHook(YoutubeDisplayPlaylistsEvent, onPlaylists); + UseMessageEventHook(YoutubeControlVideoMessageEvent, onControlVideo); const processAction = useCallback((action: string) => { switch(action) { case 'playlist_prev': - SendMessageHook(new ControlYoutubeDisplayPlaybackMessageComposer(objectId, FurnitureYoutubeDisplayWidgetHandler.CONTROL_COMMAND_PREVIOUS_VIDEO)); + SendMessageComposer(new ControlYoutubeDisplayPlaybackMessageComposer(objectId, FurnitureYoutubeDisplayWidgetHandler.CONTROL_COMMAND_PREVIOUS_VIDEO)); break; case 'playlist_next': - SendMessageHook(new ControlYoutubeDisplayPlaybackMessageComposer(objectId, FurnitureYoutubeDisplayWidgetHandler.CONTROL_COMMAND_NEXT_VIDEO)); + SendMessageComposer(new ControlYoutubeDisplayPlaybackMessageComposer(objectId, FurnitureYoutubeDisplayWidgetHandler.CONTROL_COMMAND_NEXT_VIDEO)); break; case 'video_pause': if(hasControl && videoId && videoId.length) { - SendMessageHook(new ControlYoutubeDisplayPlaybackMessageComposer(objectId, FurnitureYoutubeDisplayWidgetHandler.CONTROL_COMMAND_PAUSE_VIDEO)); + SendMessageComposer(new ControlYoutubeDisplayPlaybackMessageComposer(objectId, FurnitureYoutubeDisplayWidgetHandler.CONTROL_COMMAND_PAUSE_VIDEO)); } break; case 'video_play': if(hasControl && videoId && videoId.length) { - SendMessageHook(new ControlYoutubeDisplayPlaybackMessageComposer(objectId, FurnitureYoutubeDisplayWidgetHandler.CONTROL_COMMAND_CONTINUE_VIDEO)); + SendMessageComposer(new ControlYoutubeDisplayPlaybackMessageComposer(objectId, FurnitureYoutubeDisplayWidgetHandler.CONTROL_COMMAND_CONTINUE_VIDEO)); } break; default: if(selectedItem === action) { setSelectedItem(null); - SendMessageHook(new SetYoutubeDisplayPlaylistMessageComposer(objectId, '')); + SendMessageComposer(new SetYoutubeDisplayPlaylistMessageComposer(objectId, '')); return; } - SendMessageHook(new SetYoutubeDisplayPlaylistMessageComposer(objectId, action)); + SendMessageComposer(new SetYoutubeDisplayPlaylistMessageComposer(objectId, action)); setSelectedItem(action); } }, [hasControl, objectId, selectedItem, videoId]); diff --git a/src/views/room/widgets/infostand/InfoStandWidgetFurniView.tsx b/src/views/room/widgets/infostand/InfoStandWidgetFurniView.tsx index 247fe923..19f5c502 100644 --- a/src/views/room/widgets/infostand/InfoStandWidgetFurniView.tsx +++ b/src/views/room/widgets/infostand/InfoStandWidgetFurniView.tsx @@ -1,9 +1,9 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { CrackableDataType, GroupInformationComposer, GroupInformationEvent, RoomControllerLevel, RoomObjectCategory, RoomObjectVariable, RoomWidgetEnumItemExtradataParameter, RoomWidgetFurniInfoUsagePolicyEnum, SetObjectDataMessageComposer, StringDataType } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; -import { CreateLinkEvent, GetGroupInformation, GetRoomEngine, LocalizeText, RoomWidgetFurniActionMessage, RoomWidgetUpdateInfostandFurniEvent } from '../../../../api'; +import { CreateLinkEvent, GetGroupInformation, GetRoomEngine, LocalizeText, RoomWidgetFurniActionMessage, RoomWidgetUpdateInfostandFurniEvent, SendMessageComposer } from '../../../../api'; import { Button, Column, Flex, Text, UserProfileIconView } from '../../../../common'; -import { BatchUpdates, CreateMessageHook, SendMessageHook } from '../../../../hooks'; +import { BatchUpdates, UseMessageEventHook } from '../../../../hooks'; import { BadgeImageView } from '../../../shared/badge-image/BadgeImageView'; import { LimitedEditionCompactPlateView } from '../../../shared/limited-edition/LimitedEditionCompactPlateView'; import { RarityLevelView } from '../../../shared/rarity-level/RarityLevelView'; @@ -139,7 +139,7 @@ export const InfoStandWidgetFurniView: FC = props setGroupName(null); }); - if(furniData.groupId) SendMessageHook(new GroupInformationComposer(furniData.groupId, false)); + if(furniData.groupId) SendMessageComposer(new GroupInformationComposer(furniData.groupId, false)); }, [ roomSession, furniData ]); const onGroupInformationEvent = useCallback((event: GroupInformationEvent) => @@ -153,7 +153,7 @@ export const InfoStandWidgetFurniView: FC = props setGroupName(parser.title); }, [ furniData, groupName ]); - CreateMessageHook(GroupInformationEvent, onGroupInformationEvent); + UseMessageEventHook(GroupInformationEvent, onGroupInformationEvent); const onFurniSettingChange = useCallback((index: number, value: string) => { @@ -234,7 +234,7 @@ export const InfoStandWidgetFurniView: FC = props if((key && key.length) && (value && value.length)) map.set(key, value); } - SendMessageHook(new SetObjectDataMessageComposer(furniData.id, map)); + SendMessageComposer(new SetObjectDataMessageComposer(furniData.id, map)); break; } diff --git a/src/views/room/widgets/infostand/InfoStandWidgetRentableBotView.tsx b/src/views/room/widgets/infostand/InfoStandWidgetRentableBotView.tsx index ab16f975..fccdd2ae 100644 --- a/src/views/room/widgets/infostand/InfoStandWidgetRentableBotView.tsx +++ b/src/views/room/widgets/infostand/InfoStandWidgetRentableBotView.tsx @@ -1,9 +1,8 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { BotRemoveComposer } from '@nitrots/nitro-renderer'; import { FC, useMemo } from 'react'; -import { LocalizeText, RoomWidgetUpdateInfostandRentableBotEvent } from '../../../../api'; +import { LocalizeText, RoomWidgetUpdateInfostandRentableBotEvent, SendMessageComposer } from '../../../../api'; import { Button, Column, Flex, Text, UserProfileIconView } from '../../../../common'; -import { SendMessageHook } from '../../../../hooks'; import { AvatarImageView } from '../../../shared/avatar-image/AvatarImageView'; import { BadgeImageView } from '../../../shared/badge-image/BadgeImageView'; import { BotSkillsEnum } from '../avatar-info/common/BotSkillsEnum'; @@ -27,7 +26,7 @@ export const InfoStandWidgetRentableBotView: FC SendMessageHook(new BotRemoveComposer(rentableBotData.webID)); + const pickupBot = () => SendMessageComposer(new BotRemoveComposer(rentableBotData.webID)); if(!rentableBotData) return; diff --git a/src/views/room/widgets/infostand/InfoStandWidgetUserView.tsx b/src/views/room/widgets/infostand/InfoStandWidgetUserView.tsx index d9dc49ac..92aa5469 100644 --- a/src/views/room/widgets/infostand/InfoStandWidgetUserView.tsx +++ b/src/views/room/widgets/infostand/InfoStandWidgetUserView.tsx @@ -1,12 +1,9 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { RelationshipStatusInfoEvent, RelationshipStatusInfoMessageParser, RoomSessionUserBadgesEvent, UserRelationshipsComposer } from '@nitrots/nitro-renderer'; import { FC, FocusEvent, KeyboardEvent, useCallback, useEffect, useState } from 'react'; -import { GetConfiguration, GetGroupInformation, LocalizeText, RoomWidgetChangeMottoMessage, RoomWidgetUpdateInfostandUserEvent } from '../../../../api'; -import { Column, Text, UserProfileIconView } from '../../../../common'; -import { Base } from '../../../../common/Base'; -import { Flex } from '../../../../common/Flex'; -import { BatchUpdates, CreateMessageHook, SendMessageHook } from '../../../../hooks'; -import { CreateEventDispatcherHook } from '../../../../hooks/events'; +import { GetConfiguration, GetGroupInformation, LocalizeText, RoomWidgetChangeMottoMessage, RoomWidgetUpdateInfostandUserEvent, SendMessageComposer } from '../../../../api'; +import { Base, Column, Flex, Text, UserProfileIconView } from '../../../../common'; +import { BatchUpdates, UseEventDispatcherHook, UseMessageEventHook } from '../../../../hooks'; import { AvatarImageView } from '../../../shared/avatar-image/AvatarImageView'; import { BadgeImageView } from '../../../shared/badge-image/BadgeImageView'; import { useRoomContext } from '../../context/RoomContext'; @@ -59,7 +56,7 @@ export const InfoStandWidgetUserView: FC = props = setBadges(event.badges); }, [ userData ]); - CreateEventDispatcherHook(RoomSessionUserBadgesEvent.RSUBE_BADGES, eventDispatcher, onRoomSessionUserBadgesEvent); + UseEventDispatcherHook(RoomSessionUserBadgesEvent.RSUBE_BADGES, eventDispatcher, onRoomSessionUserBadgesEvent); const onUserRelationshipsEvent = useCallback((event: RelationshipStatusInfoEvent) => { @@ -70,7 +67,7 @@ export const InfoStandWidgetUserView: FC = props = setUserRelationships(parser); }, [ userData ]); - CreateMessageHook(RelationshipStatusInfoEvent, onUserRelationshipsEvent); + UseMessageEventHook(RelationshipStatusInfoEvent, onUserRelationshipsEvent); useEffect(() => { @@ -81,7 +78,7 @@ export const InfoStandWidgetUserView: FC = props = setMotto(userData.motto); }); - SendMessageHook(new UserRelationshipsComposer(userData.webID)); + SendMessageComposer(new UserRelationshipsComposer(userData.webID)); return () => { diff --git a/src/views/room/widgets/infostand/InfoStandWidgetView.tsx b/src/views/room/widgets/infostand/InfoStandWidgetView.tsx index ef76d03d..1a8bf5c0 100644 --- a/src/views/room/widgets/infostand/InfoStandWidgetView.tsx +++ b/src/views/room/widgets/infostand/InfoStandWidgetView.tsx @@ -1,7 +1,7 @@ import { FC, useCallback, useState } from 'react'; import { RoomWidgetRoomObjectMessage, RoomWidgetUpdateEvent, RoomWidgetUpdateInfostandEvent, RoomWidgetUpdateInfostandFurniEvent, RoomWidgetUpdateInfostandPetEvent, RoomWidgetUpdateInfostandRentableBotEvent, RoomWidgetUpdateInfostandUserEvent, RoomWidgetUpdateRoomObjectEvent } from '../../../../api'; import { Column } from '../../../../common'; -import { CreateEventDispatcherHook } from '../../../../hooks/events/event-dispatcher.base'; +import { UseEventDispatcherHook } from '../../../../hooks'; import { useRoomContext } from '../../context/RoomContext'; import { InfoStandWidgetBotView } from './InfoStandWidgetBotView'; import { InfoStandWidgetFurniView } from './InfoStandWidgetFurniView'; @@ -81,16 +81,16 @@ export const InfoStandWidgetView: FC<{}> = props => } }, [ widgetHandler, closeInfostand ]); - CreateEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.OBJECT_SELECTED, eventDispatcher, onRoomWidgetUpdateEvent); - CreateEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.OBJECT_DESELECTED, eventDispatcher, onRoomWidgetUpdateEvent); - CreateEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.USER_REMOVED, eventDispatcher, onRoomWidgetUpdateEvent); - CreateEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.FURNI_REMOVED, eventDispatcher, onRoomWidgetUpdateEvent); - CreateEventDispatcherHook(RoomWidgetUpdateInfostandFurniEvent.FURNI, eventDispatcher, onRoomWidgetUpdateEvent); - CreateEventDispatcherHook(RoomWidgetUpdateInfostandUserEvent.OWN_USER, eventDispatcher, onRoomWidgetUpdateEvent); - CreateEventDispatcherHook(RoomWidgetUpdateInfostandUserEvent.PEER, eventDispatcher, onRoomWidgetUpdateEvent); - CreateEventDispatcherHook(RoomWidgetUpdateInfostandUserEvent.BOT, eventDispatcher, onRoomWidgetUpdateEvent); - CreateEventDispatcherHook(RoomWidgetUpdateInfostandRentableBotEvent.RENTABLE_BOT, eventDispatcher, onRoomWidgetUpdateEvent); - CreateEventDispatcherHook(RoomWidgetUpdateInfostandPetEvent.PET_INFO, eventDispatcher, onRoomWidgetUpdateEvent); + UseEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.OBJECT_SELECTED, eventDispatcher, onRoomWidgetUpdateEvent); + UseEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.OBJECT_DESELECTED, eventDispatcher, onRoomWidgetUpdateEvent); + UseEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.USER_REMOVED, eventDispatcher, onRoomWidgetUpdateEvent); + UseEventDispatcherHook(RoomWidgetUpdateRoomObjectEvent.FURNI_REMOVED, eventDispatcher, onRoomWidgetUpdateEvent); + UseEventDispatcherHook(RoomWidgetUpdateInfostandFurniEvent.FURNI, eventDispatcher, onRoomWidgetUpdateEvent); + UseEventDispatcherHook(RoomWidgetUpdateInfostandUserEvent.OWN_USER, eventDispatcher, onRoomWidgetUpdateEvent); + UseEventDispatcherHook(RoomWidgetUpdateInfostandUserEvent.PEER, eventDispatcher, onRoomWidgetUpdateEvent); + UseEventDispatcherHook(RoomWidgetUpdateInfostandUserEvent.BOT, eventDispatcher, onRoomWidgetUpdateEvent); + UseEventDispatcherHook(RoomWidgetUpdateInfostandRentableBotEvent.RENTABLE_BOT, eventDispatcher, onRoomWidgetUpdateEvent); + UseEventDispatcherHook(RoomWidgetUpdateInfostandPetEvent.PET_INFO, eventDispatcher, onRoomWidgetUpdateEvent); const getInfostandView = useCallback(() => { diff --git a/src/views/room/widgets/room-thumbnail/RoomThumbnailWidgetView.tsx b/src/views/room/widgets/room-thumbnail/RoomThumbnailWidgetView.tsx index 7e499ba2..fdec765a 100644 --- a/src/views/room/widgets/room-thumbnail/RoomThumbnailWidgetView.tsx +++ b/src/views/room/widgets/room-thumbnail/RoomThumbnailWidgetView.tsx @@ -2,8 +2,8 @@ import { NitroRenderTexture } from '@nitrots/nitro-renderer'; import { FC, useCallback, useState } from 'react'; import { GetRoomEngine } from '../../../../api'; import { LayoutMiniCameraView } from '../../../../common'; -import { RoomWidgetThumbnailEvent } from '../../../../events/room-widgets/thumbnail'; -import { useUiEvent } from '../../../../hooks/events'; +import { RoomWidgetThumbnailEvent } from '../../../../events'; +import { UseUiEvent } from '../../../../hooks'; import { useRoomContext } from '../../context/RoomContext'; export const RoomThumbnailWidgetView: FC<{}> = props => @@ -27,9 +27,9 @@ export const RoomThumbnailWidgetView: FC<{}> = props => } }, []); - useUiEvent(RoomWidgetThumbnailEvent.SHOW_THUMBNAIL, onNitroEvent); - useUiEvent(RoomWidgetThumbnailEvent.HIDE_THUMBNAIL, onNitroEvent); - useUiEvent(RoomWidgetThumbnailEvent.TOGGLE_THUMBNAIL, onNitroEvent); + UseUiEvent(RoomWidgetThumbnailEvent.SHOW_THUMBNAIL, onNitroEvent); + UseUiEvent(RoomWidgetThumbnailEvent.HIDE_THUMBNAIL, onNitroEvent); + UseUiEvent(RoomWidgetThumbnailEvent.TOGGLE_THUMBNAIL, onNitroEvent); const receiveTexture = useCallback((texture: NitroRenderTexture) => { diff --git a/src/views/room/widgets/room-tools/RoomToolsWidgetView.tsx b/src/views/room/widgets/room-tools/RoomToolsWidgetView.tsx index 6766650e..6bc4a5b9 100644 --- a/src/views/room/widgets/room-tools/RoomToolsWidgetView.tsx +++ b/src/views/room/widgets/room-tools/RoomToolsWidgetView.tsx @@ -1,12 +1,10 @@ import { GetGuestRoomResultEvent, RoomLikeRoomComposer } from '@nitrots/nitro-renderer'; import classNames from 'classnames'; import { FC, useCallback, useEffect, useState } from 'react'; -import { CreateLinkEvent, LocalizeText, RoomWidgetZoomToggleMessage } from '../../../../api'; +import { CreateLinkEvent, LocalizeText, RoomWidgetZoomToggleMessage, SendMessageComposer } from '../../../../api'; import { Base, Column, Flex, Text, TransitionAnimation, TransitionAnimationTypes } from '../../../../common'; import { NavigatorEvent } from '../../../../events'; -import { BatchUpdates } from '../../../../hooks'; -import { dispatchUiEvent } from '../../../../hooks/events'; -import { CreateMessageHook, SendMessageHook } from '../../../../hooks/messages'; +import { BatchUpdates, DispatchUiEvent, UseMessageEventHook } from '../../../../hooks'; import { useRoomContext } from '../../context/RoomContext'; export const RoomToolsWidgetView: FC<{}> = props => @@ -25,7 +23,7 @@ export const RoomToolsWidgetView: FC<{}> = props => switch(action) { case 'settings': - dispatchUiEvent(new NavigatorEvent(NavigatorEvent.TOGGLE_ROOM_INFO)); + DispatchUiEvent(new NavigatorEvent(NavigatorEvent.TOGGLE_ROOM_INFO)); return; case 'zoom': widgetHandler.processWidgetMessage(new RoomWidgetZoomToggleMessage(!isZoomedIn)); @@ -37,11 +35,11 @@ export const RoomToolsWidgetView: FC<{}> = props => case 'like_room': if(isLiked) return; - SendMessageHook(new RoomLikeRoomComposer(1)); + SendMessageComposer(new RoomLikeRoomComposer(1)); setIsLiked(true); return; case 'toggle_room_link': - dispatchUiEvent(new NavigatorEvent(NavigatorEvent.TOGGLE_ROOM_LINK)); + DispatchUiEvent(new NavigatorEvent(NavigatorEvent.TOGGLE_ROOM_LINK)); return; } } @@ -58,7 +56,7 @@ export const RoomToolsWidgetView: FC<{}> = props => }); }, [ roomName, roomOwner, roomTags ]); - CreateMessageHook(GetGuestRoomResultEvent, onGetGuestRoomResultEvent); + UseMessageEventHook(GetGuestRoomResultEvent, onGetGuestRoomResultEvent); useEffect(() => { diff --git a/src/views/room/widgets/word-quiz/WordQuizWidgetView.tsx b/src/views/room/widgets/word-quiz/WordQuizWidgetView.tsx index b6b7475e..9f622471 100644 --- a/src/views/room/widgets/word-quiz/WordQuizWidgetView.tsx +++ b/src/views/room/widgets/word-quiz/WordQuizWidgetView.tsx @@ -1,8 +1,7 @@ import { IQuestion } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; -import { RoomWidgetWordQuizUpdateEvent } from '../../../../api/nitro/room/widgets/events/RoomWidgetWordQuizUpdateEvent'; -import { RoomWidgetPollMessage } from '../../../../api/nitro/room/widgets/messages/RoomWidgetPollMessage'; -import { BatchUpdates, CreateEventDispatcherHook } from '../../../../hooks'; +import { RoomWidgetPollMessage, RoomWidgetWordQuizUpdateEvent } from '../../../../api'; +import { BatchUpdates, UseEventDispatcherHook } from '../../../../hooks'; import { useRoomContext } from '../../context/RoomContext'; import { VALUE_KEY_DISLIKE, VALUE_KEY_LIKE, VoteValue } from './common/VoteValue'; import { WordQuizQuestionView } from './WordQuizQuestionView'; @@ -102,9 +101,9 @@ export const WordQuizWidgetView: FC<{}> = props => } }, [ question, roomSession.userDataManager, userAnswers, clearQuestion ]); - CreateEventDispatcherHook(RoomWidgetWordQuizUpdateEvent.NEW_QUESTION, eventDispatcher, onRoomWidgetWordQuizUpdateEvent); - CreateEventDispatcherHook(RoomWidgetWordQuizUpdateEvent.QUESTION_ANSWERED, eventDispatcher, onRoomWidgetWordQuizUpdateEvent); - CreateEventDispatcherHook(RoomWidgetWordQuizUpdateEvent.QUESTION_FINISHED, eventDispatcher, onRoomWidgetWordQuizUpdateEvent); + UseEventDispatcherHook(RoomWidgetWordQuizUpdateEvent.NEW_QUESTION, eventDispatcher, onRoomWidgetWordQuizUpdateEvent); + UseEventDispatcherHook(RoomWidgetWordQuizUpdateEvent.QUESTION_ANSWERED, eventDispatcher, onRoomWidgetWordQuizUpdateEvent); + UseEventDispatcherHook(RoomWidgetWordQuizUpdateEvent.QUESTION_FINISHED, eventDispatcher, onRoomWidgetWordQuizUpdateEvent); const vote = useCallback((vote: string) => {