From 740cfeac3148570badc019fd3f4b60d717fd55ff Mon Sep 17 00:00:00 2001 From: Bill Date: Wed, 2 Mar 2022 22:00:21 -0500 Subject: [PATCH] Delete PurseMessageHandler --- src/components/purse/PurseMessageHandler.tsx | 68 -------------------- 1 file changed, 68 deletions(-) delete mode 100644 src/components/purse/PurseMessageHandler.tsx diff --git a/src/components/purse/PurseMessageHandler.tsx b/src/components/purse/PurseMessageHandler.tsx deleted file mode 100644 index 3002b26a..00000000 --- a/src/components/purse/PurseMessageHandler.tsx +++ /dev/null @@ -1,68 +0,0 @@ -import { ActivityPointNotificationMessageEvent, UserCreditsEvent, UserCurrencyEvent, UserSubscriptionEvent, UserSubscriptionParser } from '@nitrots/nitro-renderer'; -import { FC, useCallback } from 'react'; -import { CREDITS, DUCKETS, PlaySound } from '../../api/utils/PlaySound'; -import { CreateMessageHook } from '../../hooks/messages/message-event'; -import { usePurseContext } from './PurseContext'; - -export const PurseMessageHandler: FC<{}> = props => -{ - const { purse = null } = usePurseContext(); - - const onUserCreditsEvent = useCallback((event: UserCreditsEvent) => - { - const parser = event.getParser(); - - if(purse.credits && purse.credits !== parseFloat(parser.credits)) PlaySound(CREDITS); - - purse.credits = parseFloat(parser.credits); - - purse.notify(); - }, [ purse ]); - - const onUserCurrencyEvent = useCallback((event: UserCurrencyEvent) => - { - const parser = event.getParser(); - - purse.activityPoints = parser.currencies; - - purse.notify(); - }, [ purse ]); - - const onUserCurrencyUpdateEvent = useCallback((event: ActivityPointNotificationMessageEvent) => - { - const parser = event.getParser(); - - purse.activityPoints.set(parser.type, parser.amount); - - if(parser.type === 0) PlaySound(DUCKETS); - - purse.notify(); - }, [ purse ]); - - const onUserSubscriptionEvent = useCallback((event: UserSubscriptionEvent) => - { - const parser = event.getParser(); - - const productName = parser.productName; - - if((productName !== 'club_habbo') && (productName !== 'habbo_club')) return; - - purse.clubDays = Math.max(0, parser.daysToPeriodEnd); - purse.clubPeriods = Math.max(0, parser.periodsSubscribedAhead); - purse.isVip = parser.isVip; - purse.pastClubDays = parser.pastClubDays; - purse.pastVipDays = parser.pastVipDays; - purse.isExpiring = ((parser.responseType === UserSubscriptionParser.RESPONSE_TYPE_DISCOUNT_AVAILABLE) ? true : false); - purse.minutesUntilExpiration = parser.minutesUntilExpiration; - purse.minutesSinceLastModified = parser.minutesSinceLastModified; - - purse.notify(); - }, [ purse ]); - - CreateMessageHook(UserCreditsEvent, onUserCreditsEvent); - CreateMessageHook(UserCurrencyEvent, onUserCurrencyEvent); - CreateMessageHook(ActivityPointNotificationMessageEvent, onUserCurrencyUpdateEvent); - CreateMessageHook(UserSubscriptionEvent, onUserSubscriptionEvent); - - return null; -}