From 5ca61ece5e33fd0159d0e6f0a754bbd063eada32 Mon Sep 17 00:00:00 2001 From: Bill Date: Sat, 3 Jul 2021 22:07:29 -0400 Subject: [PATCH 1/6] Add subscription to purse --- src/views/purse/PurseMessageHandler.tsx | 20 +++++++++++++++++++- src/views/purse/reducers/PurseReducer.tsx | 16 +++++++++++++--- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/views/purse/PurseMessageHandler.tsx b/src/views/purse/PurseMessageHandler.tsx index 17c5ba4f..23d474e2 100644 --- a/src/views/purse/PurseMessageHandler.tsx +++ b/src/views/purse/PurseMessageHandler.tsx @@ -1,4 +1,4 @@ -import { UserCreditsEvent, UserCurrencyEvent, UserCurrencyUpdateEvent } from 'nitro-renderer'; +import { UserCreditsEvent, UserCurrencyEvent, UserCurrencyUpdateEvent, UserSubscriptionEvent } from 'nitro-renderer'; import { FC, useCallback } from 'react'; import { CreateMessageHook } from '../../hooks/messages/message-event'; import { Currency } from './common/Currency'; @@ -48,9 +48,27 @@ export const PurseMessageHandler: FC = props => }); }, [ dispatchPurseState ]); + const onUserSubscriptionEvent = useCallback((event: UserSubscriptionEvent) => + { + const parser = event.getParser(); + + switch(parser.name) + { + case 'habbo_club': + dispatchPurseState({ + type: PurseActions.SET_CLUB_SUBSCRIPTION, + payload: { + clubSubscription: parser + } + }); + return; + } + }, [ dispatchPurseState ]); + CreateMessageHook(UserCreditsEvent, onUserCreditsEvent); CreateMessageHook(UserCurrencyEvent, onUserCurrencyEvent); CreateMessageHook(UserCurrencyUpdateEvent, onUserCurrencyUpdateEvent); + CreateMessageHook(UserSubscriptionEvent, onUserSubscriptionEvent); return null; } diff --git a/src/views/purse/reducers/PurseReducer.tsx b/src/views/purse/reducers/PurseReducer.tsx index 1a84005f..3e9d5f5b 100644 --- a/src/views/purse/reducers/PurseReducer.tsx +++ b/src/views/purse/reducers/PurseReducer.tsx @@ -1,9 +1,11 @@ +import { UserSubscriptionParser } from 'nitro-renderer'; import { Reducer } from 'react'; import { Currency } from '../common/Currency'; export interface IPurseState { currencies: Currency[]; + clubSubscription: UserSubscriptionParser; } export interface IPurseAction @@ -12,6 +14,7 @@ export interface IPurseAction payload: { currency?: Currency; currencies?: Currency[]; + clubSubscription?: UserSubscriptionParser; } } @@ -19,10 +22,12 @@ export class PurseActions { public static SET_CURRENCY: string = 'PA_SET_CURRENCY'; public static SET_CURRENCIES: string = 'PA_SET_CURRENCIES'; + public static SET_CLUB_SUBSCRIPTION: string = 'PA_SET_CLUB_SUBSCRIPTION'; } export const initialPurse: IPurseState = { - currencies: [] + currencies: [], + clubSubscription: null } export const PurseReducer: Reducer = (state, action) => @@ -34,7 +39,7 @@ export const PurseReducer: Reducer = (state, action) let didSet = false; - const currencies = state.currencies.map((existing, index) => + const currencies = state.currencies.map(existing => { if(existing.type !== updated.type) return existing; @@ -50,7 +55,7 @@ export const PurseReducer: Reducer = (state, action) case PurseActions.SET_CURRENCIES: { const updated = action.payload.currencies; - const currencies = state.currencies.filter((existing, index) => + const currencies = state.currencies.filter(existing => { if(existing.type !== -1) return null; @@ -61,6 +66,11 @@ export const PurseReducer: Reducer = (state, action) return { ...state, currencies }; } + case PurseActions.SET_CLUB_SUBSCRIPTION: { + const clubSubscription = action.payload.clubSubscription; + + return { ...state, clubSubscription }; + } default: return state; } From 28060820b594b65baea3d83ee783248acbb16846 Mon Sep 17 00:00:00 2001 From: Bill Date: Sat, 3 Jul 2021 22:14:49 -0400 Subject: [PATCH 2/6] Update some maps --- src/views/catalog/CatalogView.tsx | 4 ++-- .../catalog/views/navigation/set/CatalogNavigationSetView.tsx | 4 ++-- .../badge/active-results/InventoryActiveBadgeResultsView.tsx | 4 ++-- .../views/badge/results/InventoryBadgeResultsView.tsx | 4 ++-- .../inventory/views/bot/results/InventoryBotResultsView.tsx | 4 ++-- .../inventory/views/pet/results/InventoryPetResultsView.tsx | 4 ++-- .../room/widgets/furniture/stickie/FurnitureStickieView.tsx | 4 ++-- .../widgets/infostand/views/bot/InfoStandWidgetBotView.tsx | 4 ++-- .../views/rentable-bot/InfoStandWidgetRentableBotView.tsx | 4 ++-- .../actor-has-hand-item/WiredConditionActorHasHandItem.tsx | 4 ++-- .../WiredConditionActorIsTeamMemberView.tsx | 4 ++-- 11 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/views/catalog/CatalogView.tsx b/src/views/catalog/CatalogView.tsx index 4ee80c6a..cbe8faab 100644 --- a/src/views/catalog/CatalogView.tsx +++ b/src/views/catalog/CatalogView.tsx @@ -93,10 +93,10 @@ export const CatalogView: FC = props => setIsVisible(false) } /> - { root && root.children.length && root.children.map((page, index) => + { root && root.children.length && root.children.map(page => { return ( - setCurrentTab(page) }> + setCurrentTab(page) }> { page.localization } ); diff --git a/src/views/catalog/views/navigation/set/CatalogNavigationSetView.tsx b/src/views/catalog/views/navigation/set/CatalogNavigationSetView.tsx index 32a8ec30..32d5e54d 100644 --- a/src/views/catalog/views/navigation/set/CatalogNavigationSetView.tsx +++ b/src/views/catalog/views/navigation/set/CatalogNavigationSetView.tsx @@ -35,11 +35,11 @@ export const CatalogNavigationSetView: FC = props return (
- { page && (page.children.length > 0) && page.children.map((page, index) => + { page && (page.children.length > 0) && page.children.map(page => { if(!page.visible) return null; - return + return }) }
); diff --git a/src/views/inventory/views/badge/active-results/InventoryActiveBadgeResultsView.tsx b/src/views/inventory/views/badge/active-results/InventoryActiveBadgeResultsView.tsx index d8f970af..75f3785d 100644 --- a/src/views/inventory/views/badge/active-results/InventoryActiveBadgeResultsView.tsx +++ b/src/views/inventory/views/badge/active-results/InventoryActiveBadgeResultsView.tsx @@ -8,9 +8,9 @@ export const InventoryActiveBadgeResultsView: FC - { badges && (badges.length > 0) && badges.map((code, index) => + { badges && (badges.length > 0) && badges.map(code => { - return + return }) } ); diff --git a/src/views/inventory/views/badge/results/InventoryBadgeResultsView.tsx b/src/views/inventory/views/badge/results/InventoryBadgeResultsView.tsx index d563979b..66215373 100644 --- a/src/views/inventory/views/badge/results/InventoryBadgeResultsView.tsx +++ b/src/views/inventory/views/badge/results/InventoryBadgeResultsView.tsx @@ -9,11 +9,11 @@ export const InventoryBadgeResultsView: FC = pro return (
- { badges && (badges.length > 0) && badges.map((code, index) => + { badges && (badges.length > 0) && badges.map(code => { if(activeBadges.indexOf(code) >= 0) return null; - return + return }) }
diff --git a/src/views/inventory/views/bot/results/InventoryBotResultsView.tsx b/src/views/inventory/views/bot/results/InventoryBotResultsView.tsx index 05e044fb..477c7bb4 100644 --- a/src/views/inventory/views/bot/results/InventoryBotResultsView.tsx +++ b/src/views/inventory/views/bot/results/InventoryBotResultsView.tsx @@ -9,9 +9,9 @@ export const InventoryBotResultsView: FC = props = return (
- { botItems && (botItems.length > 0) && botItems.map((item, index) => + { botItems && (botItems.length > 0) && botItems.map(item => { - return + return }) }
diff --git a/src/views/inventory/views/pet/results/InventoryPetResultsView.tsx b/src/views/inventory/views/pet/results/InventoryPetResultsView.tsx index 03fc893e..21e99114 100644 --- a/src/views/inventory/views/pet/results/InventoryPetResultsView.tsx +++ b/src/views/inventory/views/pet/results/InventoryPetResultsView.tsx @@ -9,9 +9,9 @@ export const InventoryPetResultsView: FC = props = return (
- { petItems && (petItems.length > 0) && petItems.map((item, index) => + { petItems && (petItems.length > 0) && petItems.map(item => { - return + return }) }
diff --git a/src/views/room/widgets/furniture/stickie/FurnitureStickieView.tsx b/src/views/room/widgets/furniture/stickie/FurnitureStickieView.tsx index 2c1a7a97..3a34020b 100644 --- a/src/views/room/widgets/furniture/stickie/FurnitureStickieView.tsx +++ b/src/views/room/widgets/furniture/stickie/FurnitureStickieView.tsx @@ -122,9 +122,9 @@ export const FurnitureStickieView: FC = props => { stickieData.canModify && <>
processAction('trash') }>
- { STICKIE_COLORS.map((color, index) => + { STICKIE_COLORS.map(color => { - return
processAction('changeColor', color) } style={ {backgroundColor: ColorUtils.makeColorHex(color) } } /> + return
processAction('changeColor', color) } style={ {backgroundColor: ColorUtils.makeColorHex(color) } } /> })} }
diff --git a/src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.tsx b/src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.tsx index 45c2eb20..dedf8822 100644 --- a/src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.tsx +++ b/src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.tsx @@ -24,9 +24,9 @@ export const InfoStandWidgetBotView: FC = props =>
- { (botData.badges.length > 0) && botData.badges.map((result, index) => + { (botData.badges.length > 0) && botData.badges.map(result => { - return ; + return ; }) }
diff --git a/src/views/room/widgets/infostand/views/rentable-bot/InfoStandWidgetRentableBotView.tsx b/src/views/room/widgets/infostand/views/rentable-bot/InfoStandWidgetRentableBotView.tsx index 258840ef..a25fc8d3 100644 --- a/src/views/room/widgets/infostand/views/rentable-bot/InfoStandWidgetRentableBotView.tsx +++ b/src/views/room/widgets/infostand/views/rentable-bot/InfoStandWidgetRentableBotView.tsx @@ -36,9 +36,9 @@ export const InfoStandWidgetRentableBotView: FC
- { (rentableBotData.badges.length > 0) && rentableBotData.badges.map((result, index) => + { (rentableBotData.badges.length > 0) && rentableBotData.badges.map(result => { - return ; + return ; }) }
diff --git a/src/views/wired/views/conditions/actor-has-hand-item/WiredConditionActorHasHandItem.tsx b/src/views/wired/views/conditions/actor-has-hand-item/WiredConditionActorHasHandItem.tsx index fe4aefe3..368b3114 100644 --- a/src/views/wired/views/conditions/actor-has-hand-item/WiredConditionActorHasHandItem.tsx +++ b/src/views/wired/views/conditions/actor-has-hand-item/WiredConditionActorHasHandItem.tsx @@ -26,9 +26,9 @@ export const WiredConditionActorHasHandItemView: FC<{}> = props =>
diff --git a/src/views/wired/views/conditions/actor-is-team-member/WiredConditionActorIsTeamMemberView.tsx b/src/views/wired/views/conditions/actor-is-team-member/WiredConditionActorIsTeamMemberView.tsx index 851088a3..b616db4b 100644 --- a/src/views/wired/views/conditions/actor-is-team-member/WiredConditionActorIsTeamMemberView.tsx +++ b/src/views/wired/views/conditions/actor-is-team-member/WiredConditionActorIsTeamMemberView.tsx @@ -25,10 +25,10 @@ export const WiredConditionActorIsTeamMemberView: FC<{}> = props =>
- { teamIds.map((value, index) => + { teamIds.map(value => { return ( -
+
setSelectedTeam(value) } />