From e35bfde81682c23669e6e2bcde1ee051c5f0ffd6 Mon Sep 17 00:00:00 2001 From: Bill Date: Wed, 3 Aug 2022 10:13:45 -0400 Subject: [PATCH] Infostand layout changes --- ...nfoStandWidgetUserRelationshipItemView.tsx | 31 +++++++++++++++ .../InfoStandWidgetUserRelationshipsView.tsx | 35 +++-------------- .../infostand/InfoStandWidgetUserView.tsx | 38 ++++++++++--------- 3 files changed, 56 insertions(+), 48 deletions(-) create mode 100644 src/components/room/widgets/avatar-info/infostand/InfoStandWidgetUserRelationshipItemView.tsx diff --git a/src/components/room/widgets/avatar-info/infostand/InfoStandWidgetUserRelationshipItemView.tsx b/src/components/room/widgets/avatar-info/infostand/InfoStandWidgetUserRelationshipItemView.tsx new file mode 100644 index 00000000..95911931 --- /dev/null +++ b/src/components/room/widgets/avatar-info/infostand/InfoStandWidgetUserRelationshipItemView.tsx @@ -0,0 +1,31 @@ +import { RelationshipStatusEnum, RelationshipStatusInfo } from '@nitrots/nitro-renderer'; +import { FC } from 'react'; +import { GetUserProfile, LocalizeText } from '../../../../../api'; +import { Flex, Text } from '../../../../../common'; + +interface InfoStandWidgetUserRelationshipsRelationshipItemViewProps +{ + type: number; + relationship: RelationshipStatusInfo; +} + +export const InfoStandWidgetUserRelationshipsRelationshipItemView: FC = props => +{ + const { type = -1, relationship = null } = props; + + if(!relationship) return null; + + const relationshipName = RelationshipStatusEnum.RELATIONSHIP_NAMES[type].toLocaleLowerCase(); + + return ( + + + + GetUserProfile(relationship.randomFriendId) }> + { relationship.randomFriendName } + { (relationship.friendCount > 1) && (' ' + LocalizeText(`extendedprofile.relstatus.others.${ relationshipName }`, [ 'count' ], [ (relationship.friendCount - 1).toString() ])) } + + + + ); +} diff --git a/src/components/room/widgets/avatar-info/infostand/InfoStandWidgetUserRelationshipsView.tsx b/src/components/room/widgets/avatar-info/infostand/InfoStandWidgetUserRelationshipsView.tsx index 0a71a09a..bd280ffd 100644 --- a/src/components/room/widgets/avatar-info/infostand/InfoStandWidgetUserRelationshipsView.tsx +++ b/src/components/room/widgets/avatar-info/infostand/InfoStandWidgetUserRelationshipsView.tsx @@ -1,48 +1,23 @@ import { RelationshipStatusEnum, RelationshipStatusInfoMessageParser } from '@nitrots/nitro-renderer'; import { FC } from 'react'; -import { GetUserProfile, LocalizeText } from '../../../../../api'; -import { Flex, Text } from '../../../../../common'; +import { InfoStandWidgetUserRelationshipsRelationshipItemView } from './InfoStandWidgetUserRelationshipItemView'; interface InfoStandWidgetUserRelationshipsViewProps { relationships: RelationshipStatusInfoMessageParser; } -interface InfoStandWidgetUserRelationshipsRelationshipViewProps -{ - type: number; -} - export const InfoStandWidgetUserRelationshipsView: FC = props => { const { relationships = null } = props; - const RelationshipComponent = ({ type }: InfoStandWidgetUserRelationshipsRelationshipViewProps) => - { - const relationshipInfo = (relationships && relationships.relationshipStatusMap.hasKey(type)) ? relationships.relationshipStatusMap.getValue(type) : null; - - if(!relationshipInfo || !relationshipInfo.friendCount) return null; - - const relationshipName = RelationshipStatusEnum.RELATIONSHIP_NAMES[type].toLocaleLowerCase(); - - return ( - - - - GetUserProfile(relationshipInfo.randomFriendId) }> - { relationshipInfo.randomFriendName } - { (relationshipInfo.friendCount > 1) && (' ' + LocalizeText(`extendedprofile.relstatus.others.${ relationshipName }`, [ 'count' ], [ (relationshipInfo.friendCount - 1).toString() ])) } - - - - ); - } + if(!relationships || !relationships.relationshipStatusMap.length) return null; return ( <> - - - + + + ); } diff --git a/src/components/room/widgets/avatar-info/infostand/InfoStandWidgetUserView.tsx b/src/components/room/widgets/avatar-info/infostand/InfoStandWidgetUserView.tsx index a0e4086b..238ffae1 100644 --- a/src/components/room/widgets/avatar-info/infostand/InfoStandWidgetUserView.tsx +++ b/src/components/room/widgets/avatar-info/infostand/InfoStandWidgetUserView.tsx @@ -2,7 +2,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { RelationshipStatusInfoEvent, RelationshipStatusInfoMessageParser, RoomSessionFavoriteGroupUpdateEvent, RoomSessionUserBadgesEvent, RoomSessionUserFigureUpdateEvent, UserRelationshipsComposer } from '@nitrots/nitro-renderer'; import { Dispatch, FC, FocusEvent, KeyboardEvent, SetStateAction, useEffect, useState } from 'react'; import { AvatarInfoUser, CloneObject, GetConfiguration, GetGroupInformation, GetSessionDataManager, GetUserProfile, LocalizeText, SendMessageComposer } from '../../../../../api'; -import { Base, Column, Flex, LayoutAvatarImageView, LayoutBadgeImageView, Text, UserProfileIconView } from '../../../../../common'; +import { Column, Flex, LayoutAvatarImageView, LayoutBadgeImageView, Text, UserProfileIconView } from '../../../../../common'; import { useMessageEvent, useRoom, useRoomSessionManagerEvent } from '../../../../../hooks'; import { InfoStandWidgetUserRelationshipsView } from './InfoStandWidgetUserRelationshipsView'; @@ -20,7 +20,6 @@ export const InfoStandWidgetUserView: FC = props = const [ isEditingMotto, setIsEditingMotto ] = useState(false); const [ relationships, setRelationships ] = useState(null); const { roomSession = null } = useRoom(); - const maxBadgeCount = GetConfiguration('user.badges.max.slots', 5); const saveMotto = (motto: string) => { @@ -49,6 +48,10 @@ export const InfoStandWidgetUserView: FC = props = { if(!avatarInfo || (avatarInfo.webID !== event.userId)) return; + const oldBadges = avatarInfo.badges.join(''); + + if(oldBadges === event.badges.join('')) return; + setAvatarInfo(prevValue => { const newValue = CloneObject(prevValue); @@ -82,7 +85,6 @@ export const InfoStandWidgetUserView: FC = props = setAvatarInfo(prevValue => { const newValue = CloneObject(prevValue); - const clearGroup = ((event.status === -1) || (event.habboGroupId <= 0)); newValue.groupId = clearGroup ? -1 : event.habboGroupId; @@ -137,31 +139,31 @@ export const InfoStandWidgetUserView: FC = props = GetUserProfile(avatarInfo.webID) }> - + - + { avatarInfo.badges[0] && } - - 0) } className="badge-image" onClick={ event => GetGroupInformation(avatarInfo.groupId) }> + + 0) } className="badge-image" onClick={ event => GetGroupInformation(avatarInfo.groupId) }> { avatarInfo.groupId > 0 && } - + - - + + { avatarInfo.badges[1] && } - - + + { avatarInfo.badges[2] && } - + - - + + { avatarInfo.badges[3] && } - - + + { avatarInfo.badges[4] && } - +