diff --git a/public/configuration.json b/public/configuration.json index c2a60512..457b921d 100644 --- a/public/configuration.json +++ b/public/configuration.json @@ -2,6 +2,7 @@ "socket.url": "wss://ws.nitrots.co:2096", "asset.url": "https://nitro.nitrots.co", "image.library.url": "https://swf.nitrots.co/c_images/", + "internal.samples.url": "", "external.samples.url": "https://swf.nitrots.co/dcr/hof_furni/mp3/sound_machine_sample_%sample%.mp3", "image.library.notifications.url": "${image.library.url}notifications/%image%.png", "achievements.images.url": "${image.library.url}Quests/%image%.png", diff --git a/src/views/friend-list/reducers/FriendListReducer.tsx b/src/views/friend-list/reducers/FriendListReducer.tsx index 33a8a41c..8052b06c 100644 --- a/src/views/friend-list/reducers/FriendListReducer.tsx +++ b/src/views/friend-list/reducers/FriendListReducer.tsx @@ -103,7 +103,7 @@ export const FriendListReducer: Reducer = ( for(const friend of update.addedFriends) processUpdate(friend); - for(const friend of update.addedFriends) processUpdate(friend); + for(const friend of update.updatedFriends) processUpdate(friend); for(const removedFriendId of update.removedFriendIds) { diff --git a/src/views/friend-list/views/friend-bar-item/FriendBarItemView.tsx b/src/views/friend-list/views/friend-bar-item/FriendBarItemView.tsx index 8cc36663..0cd1049c 100644 --- a/src/views/friend-list/views/friend-bar-item/FriendBarItemView.tsx +++ b/src/views/friend-list/views/friend-bar-item/FriendBarItemView.tsx @@ -1,5 +1,6 @@ -import { FollowFriendComposer, MouseEventType, Nitro } from 'nitro-renderer'; -import { FC, useEffect, useRef, useState } from 'react'; +import { FollowFriendComposer, MouseEventType } from 'nitro-renderer'; +import { FC, useCallback, useEffect, useRef, useState } from 'react'; +import { GetConnection } from '../../../../api'; import { LocalizeText } from '../../../../utils/LocalizeText'; import { AvatarImageView } from '../../../shared/avatar-image/AvatarImageView'; import { FriendBarItemViewProps } from './FriendBarItemView.types'; @@ -7,38 +8,33 @@ import { FriendBarItemViewProps } from './FriendBarItemView.types'; export const FriendBarItemView: FC = props => { const { friend = null } = props; - const [isVisible, setVisible] = useState(false); - - const toggleVisible = () => setVisible(prevCheck => !prevCheck); - + const [ isVisible, setVisible ] = useState(false); const elementRef = useRef(); + const followFriend = useCallback(() => + { + GetConnection().send(new FollowFriendComposer(friend.id)); + }, [ friend ]); + + const onClick = useCallback((event: MouseEvent) => + { + const element = elementRef.current; + + if((event.target !== element) && !element.contains((event.target as Node))) + { + setVisible(false); + } + }, []); + useEffect(() => { - function onClick(event: MouseEvent): void - { - const element = elementRef.current; - - if((event.target !== element) && !element.contains((event.target as Node))) - { - setVisible(false); - } - } - document.addEventListener(MouseEventType.MOUSE_CLICK, onClick); return () => { document.removeEventListener(MouseEventType.MOUSE_CLICK, onClick); } - }, [ elementRef, setVisible ]); - - - const followFriend = () => - { - - Nitro.instance.communication.connection.send(new FollowFriendComposer(friend.id)); - } + }, [ onClick ]); if(!friend) { @@ -51,16 +47,17 @@ export const FriendBarItemView: FC = props => } return ( -
toggleVisible()}> +
setVisible(prevValue => !prevValue) }>
- +
-
{friend.name}
- {isVisible &&
- - {friend.followingAllowed && followFriend() } className="icon icon-fb-visit cursor-pointer" />} - -
} +
{ friend.name }
+ { isVisible && +
+ + { friend.followingAllowed && } + +
}
); } diff --git a/src/views/friend-list/views/friend-bar/FriendBarView.tsx b/src/views/friend-list/views/friend-bar/FriendBarView.tsx index 59748b94..b1836e64 100644 --- a/src/views/friend-list/views/friend-bar/FriendBarView.tsx +++ b/src/views/friend-list/views/friend-bar/FriendBarView.tsx @@ -8,6 +8,12 @@ export const FriendBarView: FC = props => const { friendListState = null } = useFriendListContext(); const { friends = null } = friendListState; const [ indexOffset, setIndexOffset ] = useState(0); + const [ maxDisplayCount, setMaxDisplayCount ] = useState(3); + + const onlineFriends = useMemo(() => + { + return friends.filter(friend => friend.online); + }, [ friends ]); const canDecreaseIndex = useMemo(() => { @@ -18,20 +24,21 @@ export const FriendBarView: FC = props => const canIncreaseIndex = useMemo(() => { - if(indexOffset === (friends.length - 1)) return false; + if((onlineFriends.length <= maxDisplayCount) || (indexOffset === (onlineFriends.length - 1))) return false; return true; - }, [ indexOffset, friends ]); + }, [ maxDisplayCount, indexOffset, onlineFriends ]); 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/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; } 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) } />