diff --git a/src/components/catalog/CatalogMessageHandler.tsx b/src/components/catalog/CatalogMessageHandler.tsx index 41ed317a..3e3e2552 100644 --- a/src/components/catalog/CatalogMessageHandler.tsx +++ b/src/components/catalog/CatalogMessageHandler.tsx @@ -1,4 +1,4 @@ -import { ApproveNameMessageEvent, CatalogPageMessageEvent, CatalogPagesListEvent, CatalogPublishedMessageEvent, ClubGiftInfoEvent, GiftReceiverNotFoundEvent, GiftWrappingConfigurationEvent, HabboClubOffersMessageEvent, LimitedEditionSoldOutEvent, MarketplaceMakeOfferResult, NodeData, ProductOfferEvent, PurchaseErrorMessageEvent, PurchaseNotAllowedMessageEvent, PurchaseOKMessageEvent, SellablePetPalettesMessageEvent, UserSubscriptionEvent } from '@nitrots/nitro-renderer'; +import { ApproveNameMessageEvent, CatalogPageMessageEvent, CatalogPagesListEvent, ClubGiftInfoEvent, GiftReceiverNotFoundEvent, GiftWrappingConfigurationEvent, HabboClubOffersMessageEvent, LimitedEditionSoldOutEvent, MarketplaceMakeOfferResult, NodeData, ProductOfferEvent, PurchaseErrorMessageEvent, PurchaseNotAllowedMessageEvent, PurchaseOKMessageEvent, SellablePetPalettesMessageEvent, UserSubscriptionEvent } from '@nitrots/nitro-renderer'; import { GuildMembershipsMessageEvent } from '@nitrots/nitro-renderer/src/nitro/communication/messages/incoming/user/GuildMembershipsMessageEvent'; import { FC, useCallback } from 'react'; import { GetFurnitureData, GetProductDataForLocalization, LocalizeText, NotificationAlertType, NotificationUtilities } from '../../api'; @@ -251,13 +251,6 @@ export const CatalogMessageHandler: FC<{}> = props => }); }, [ setCatalogOptions ]); - const onCatalogPublishedMessageEvent = useCallback((event: CatalogPublishedMessageEvent) => - { - resetState(); - - NotificationUtilities.simpleAlert(LocalizeText('catalog.alert.published.description'), null, null, null, LocalizeText('catalog.alert.published.title')); - }, [ resetState ]); - const onGiftWrappingConfigurationEvent = useCallback((event: GiftWrappingConfigurationEvent) => { const parser = event.getParser(); @@ -316,7 +309,6 @@ export const CatalogMessageHandler: FC<{}> = props => UseMessageEventHook(GiftReceiverNotFoundEvent, onGiftReceiverNotFoundEvent); UseMessageEventHook(HabboClubOffersMessageEvent, onHabboClubOffersMessageEvent); UseMessageEventHook(UserSubscriptionEvent, onUserSubscriptionEvent); - UseMessageEventHook(CatalogPublishedMessageEvent, onCatalogPublishedMessageEvent); UseMessageEventHook(GiftWrappingConfigurationEvent, onGiftWrappingConfigurationEvent); UseMessageEventHook(ClubGiftInfoEvent, onClubGiftInfoEvent); UseMessageEventHook(MarketplaceMakeOfferResult, onMarketplaceMakeOfferResult); diff --git a/src/components/catalog/CatalogView.tsx b/src/components/catalog/CatalogView.tsx index d54e9b15..97d86efa 100644 --- a/src/components/catalog/CatalogView.tsx +++ b/src/components/catalog/CatalogView.tsx @@ -1,9 +1,9 @@ -import { FrontPageItem, GetCatalogIndexComposer, GetCatalogPageComposer, GetClubGiftInfo, GetGiftWrappingConfigurationComposer, ILinkEventTracker, RoomPreviewer } from '@nitrots/nitro-renderer'; +import { CatalogPublishedMessageEvent, FrontPageItem, GetCatalogIndexComposer, GetCatalogPageComposer, GetClubGiftInfo, GetGiftWrappingConfigurationComposer, ILinkEventTracker, RoomPreviewer } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; -import { AddEventLinkTracker, GetRoomEngine, LocalizeText, PlaySound, RemoveLinkEventTracker, SendMessageComposer, SoundNames } from '../../api'; +import { AddEventLinkTracker, GetRoomEngine, LocalizeText, NotificationUtilities, PlaySound, RemoveLinkEventTracker, SendMessageComposer, SoundNames } from '../../api'; import { Column, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../common'; import { CatalogPurchasedEvent } from '../../events'; -import { BatchUpdates, UseUiEvent } from '../../hooks'; +import { BatchUpdates, UseMessageEventHook, UseUiEvent } from '../../hooks'; import { CatalogContextProvider } from './CatalogContext'; import { CatalogMessageHandler } from './CatalogMessageHandler'; import { CatalogPage } from './common/CatalogPage'; @@ -59,6 +59,17 @@ export const CatalogView: FC<{}> = props => }); }, []); + const onCatalogPublishedMessageEvent = useCallback((event: CatalogPublishedMessageEvent) => + { + const wasVisible = isVisible; + + resetState(); + + if(wasVisible) NotificationUtilities.simpleAlert(LocalizeText('catalog.alert.published.description'), null, null, null, LocalizeText('catalog.alert.published.title')); + }, [ isVisible, resetState ]); + + UseMessageEventHook(CatalogPublishedMessageEvent, onCatalogPublishedMessageEvent); + const getNodeById = useCallback((id: number, node: ICatalogNode) => { if((node.pageId === id) && (node !== rootNode)) return node;