From 6474a880001c74b431b391a4b76ad41881dcc95d Mon Sep 17 00:00:00 2001 From: Bill Date: Fri, 11 Mar 2022 00:42:01 -0500 Subject: [PATCH] Update friends list --- src/common/card/NitroCardHeaderView.tsx | 2 +- src/common/card/NitroCardView.scss | 6 +- .../friends-group/FriendsGroupItemView.tsx | 93 ------------ .../views/friends-group/FriendsGroupView.tsx | 26 ---- .../views/friends-list/FriendsListView.tsx | 66 ++++---- .../FriendsRemoveConfirmationView.tsx | 14 +- .../friends-list/FriendsRoomInviteView.tsx | 32 ++++ .../views/friends-list/FriendsSearchView.tsx | 141 ++++++++++++++++++ .../FriendsListGroupItemView.tsx | 93 ++++++++++++ .../FriendsListGroupView.tsx | 24 +++ .../FriendsListRequestItemView.tsx | 31 ++++ .../FriendsListRequestView.tsx | 35 +++++ .../FriendsRequestItemView.tsx | 28 ---- .../friends-request/FriendsRequestView.tsx | 33 ---- .../FriendsRoomInviteView.tsx | 32 ---- .../friends-search/FriendsSearchView.tsx | 79 ---------- 16 files changed, 392 insertions(+), 343 deletions(-) delete mode 100644 src/views/friends/views/friends-group/FriendsGroupItemView.tsx delete mode 100644 src/views/friends/views/friends-group/FriendsGroupView.tsx rename src/views/friends/views/{friends-remove-confirmation => friends-list}/FriendsRemoveConfirmationView.tsx (56%) create mode 100644 src/views/friends/views/friends-list/FriendsRoomInviteView.tsx create mode 100644 src/views/friends/views/friends-list/FriendsSearchView.tsx create mode 100644 src/views/friends/views/friends-list/friends-list-group/FriendsListGroupItemView.tsx create mode 100644 src/views/friends/views/friends-list/friends-list-group/FriendsListGroupView.tsx create mode 100644 src/views/friends/views/friends-list/friends-list-request/FriendsListRequestItemView.tsx create mode 100644 src/views/friends/views/friends-list/friends-list-request/FriendsListRequestView.tsx delete mode 100644 src/views/friends/views/friends-request/FriendsRequestItemView.tsx delete mode 100644 src/views/friends/views/friends-request/FriendsRequestView.tsx delete mode 100644 src/views/friends/views/friends-room-invite/FriendsRoomInviteView.tsx delete mode 100644 src/views/friends/views/friends-search/FriendsSearchView.tsx diff --git a/src/common/card/NitroCardHeaderView.tsx b/src/common/card/NitroCardHeaderView.tsx index 1f251e2f..abc84ce2 100644 --- a/src/common/card/NitroCardHeaderView.tsx +++ b/src/common/card/NitroCardHeaderView.tsx @@ -32,7 +32,7 @@ export const NitroCardHeaderView: FC = props => { headerText } - + diff --git a/src/common/card/NitroCardView.scss b/src/common/card/NitroCardView.scss index c8440bb3..f1a85fac 100644 --- a/src/common/card/NitroCardView.scss +++ b/src/common/card/NitroCardView.scss @@ -61,8 +61,8 @@ $nitro-card-tabs-height: 33px; .nitro-card-header { position: relative; - min-height: 27px; - max-height: 27px; + min-height: 28px; + max-height: 28px; background: repeating-linear-gradient($tertiary, $tertiary 50%, $quaternary 50%, $quaternary 100%); border-bottom: 2px solid darken($quaternary, 5); box-shadow: 0 2px white; @@ -87,7 +87,7 @@ $nitro-card-tabs-height: 33px; .nitro-card-header-close { cursor: pointer; - padding: 0px 2px; + padding: 0px 1px; line-height: 1; @include font-size($h7-font-size); border-radius: $border-radius; diff --git a/src/views/friends/views/friends-group/FriendsGroupItemView.tsx b/src/views/friends/views/friends-group/FriendsGroupItemView.tsx deleted file mode 100644 index 35a9ba28..00000000 --- a/src/views/friends/views/friends-group/FriendsGroupItemView.tsx +++ /dev/null @@ -1,93 +0,0 @@ -import { FollowFriendMessageComposer, SetRelationshipStatusComposer } from '@nitrots/nitro-renderer'; -import classNames from 'classnames'; -import { FC, useCallback, useState } from 'react'; -import { LocalizeText, OpenMessengerChat, SendMessageComposer } from '../../../../api'; -import { Base, Flex, FlexProps, UserProfileIconView } from '../../../../common'; -import { MessengerFriend } from '../../common/MessengerFriend'; - -interface FriendsGroupItemViewProps extends FlexProps -{ - friend: MessengerFriend; - selected?: boolean; - selectFriend: () => void; -} - -export const FriendsGroupItemView: FC = props => -{ - const { friend = null, selected = false, selectFriend = null, children = null, ...rest } = props; - - const [ isExpanded, setIsExpanded ] = useState(false); - - const followFriend = useCallback(() => - { - if(!friend) return; - - SendMessageComposer(new FollowFriendMessageComposer(friend.id)); - }, [ friend ]); - - const openMessengerChat = useCallback((e) => - { - e.stopPropagation(); - - if(!friend) return; - - OpenMessengerChat(friend.id); - }, [ friend ]); - - const getCurrentRelationshipName = useCallback(() => - { - if(!friend) return 'none'; - - switch(friend.relationshipStatus) - { - case MessengerFriend.RELATIONSHIP_HEART: return 'heart'; - case MessengerFriend.RELATIONSHIP_SMILE: return 'smile'; - case MessengerFriend.RELATIONSHIP_BOBBA: return 'bobba'; - default: return 'none'; - } - }, [ friend ]); - - const initUpdateRelationship = useCallback((e) => - { - e.stopPropagation(); - setIsExpanded(true); - }, []); - - const updateRelationship = useCallback((e, type: number) => - { - e.stopPropagation(); - - if(type !== friend.relationshipStatus) SendMessageComposer(new SetRelationshipStatusComposer(friend.id, type)); - - setIsExpanded(false); - }, [ friend ]); - - if(!friend) return null; - - return ( - -
e.stopPropagation() }> - -
-
{ friend.name }
- - { !isExpanded && - <> - { friend.followingAllowed && - } - { friend.online && - } - - } - { isExpanded && - <> - updateRelationship(e, MessengerFriend.RELATIONSHIP_HEART) } /> - updateRelationship(e, MessengerFriend.RELATIONSHIP_SMILE) } /> - updateRelationship(e, MessengerFriend.RELATIONSHIP_BOBBA) } /> - updateRelationship(e, MessengerFriend.RELATIONSHIP_NONE) } /> - } - - { children } -
- ); -} diff --git a/src/views/friends/views/friends-group/FriendsGroupView.tsx b/src/views/friends/views/friends-group/FriendsGroupView.tsx deleted file mode 100644 index 0094490d..00000000 --- a/src/views/friends/views/friends-group/FriendsGroupView.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import { FC } from 'react'; -import { MessengerFriend } from '../../common/MessengerFriend'; -import { FriendsGroupItemView } from './FriendsGroupItemView'; - -interface FriendsGroupViewProps -{ - list: MessengerFriend[]; - selectedFriendsIds: number[]; - selectFriend: (userId: number) => void; -} - -export const FriendsGroupView: FC = props => -{ - const { list = null, selectedFriendsIds = null, selectFriend = null } = props; - - if(!list) return null; - - return ( - <> - { selectedFriendsIds && list && list.map((item, index) => - { - return selectFriend(item.id) } />; - }) } - - ); -} diff --git a/src/views/friends/views/friends-list/FriendsListView.tsx b/src/views/friends/views/friends-list/FriendsListView.tsx index 334c6e78..8c2d0244 100644 --- a/src/views/friends/views/friends-list/FriendsListView.tsx +++ b/src/views/friends/views/friends-list/FriendsListView.tsx @@ -1,14 +1,14 @@ import { RemoveFriendComposer, SendRoomInviteComposer } from '@nitrots/nitro-renderer'; import { FC, useCallback, useMemo, useState } from 'react'; import { LocalizeText, SendMessageComposer } from '../../../../api'; -import { NitroCardAccordionSetView, NitroCardAccordionView, NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../../../common'; +import { Button, Flex, NitroCardAccordionSetView, NitroCardAccordionView, NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../common'; import { MessengerFriend } from '../../common/MessengerFriend'; import { MessengerRequest } from '../../common/MessengerRequest'; -import { FriendsGroupView } from '../friends-group/FriendsGroupView'; -import { FriendsRemoveConfirmationView } from '../friends-remove-confirmation/FriendsRemoveConfirmationView'; -import { FriendsRequestView } from '../friends-request/FriendsRequestView'; -import { FriendsRoomInviteView } from '../friends-room-invite/FriendsRoomInviteView'; -import { FriendsSearchView } from '../friends-search/FriendsSearchView'; +import { FriendsListGroupView } from './friends-list-group/FriendsListGroupView'; +import { FriendsListRequestView } from './friends-list-request/FriendsListRequestView'; +import { FriendsRemoveConfirmationView } from './FriendsRemoveConfirmationView'; +import { FriendsRoomInviteView } from './FriendsRoomInviteView'; +import { FriendsSearchView } from './FriendsSearchView'; interface FriendsListViewProps { @@ -18,15 +18,11 @@ interface FriendsListViewProps friendRequests: MessengerRequest[]; } -const MODE_FRIENDS: number = 0; -const MODE_SEARCH: number = 1; - export const FriendsListView: FC = props => { const { onlineFriends = [], offlineFriends = [], friendRequests = [], onCloseClick = null } = props; const [ selectedFriendsIds, setSelectedFriendsIds ] = useState([]); - const [ mode, setMode ] = useState(0); const [ showRoomInvite, setShowRoomInvite ] = useState(false); const [ showRemoveFriendsConfirmation, setShowRemoveFriendsConfirmation ] = useState(false); @@ -89,42 +85,30 @@ export const FriendsListView: FC = props => return ( <> - + - - setMode(MODE_FRIENDS) }> - { LocalizeText('friendlist.friends') } - - setMode(MODE_SEARCH) }> - { LocalizeText('generic.search') } - - - - { (mode === MODE_FRIENDS) && - <> - - - - - - - - - - { selectedFriendsIds && selectedFriendsIds.length > 0 &&
- - -
} - - } - { (mode === MODE_SEARCH) && - } + + + + + + + + + + + + { selectedFriendsIds && selectedFriendsIds.length > 0 && + + + + }
{ showRoomInvite && - setShowRoomInvite(false) } sendRoomInvite={ sendRoomInvite } /> } + setShowRoomInvite(false) } sendRoomInvite={ sendRoomInvite } /> } { showRemoveFriendsConfirmation && - setShowRemoveFriendsConfirmation(false) } removeSelectedFriends={ removeSelectedFriends } /> } + setShowRemoveFriendsConfirmation(false) } removeSelectedFriends={ removeSelectedFriends } /> } ); }; diff --git a/src/views/friends/views/friends-remove-confirmation/FriendsRemoveConfirmationView.tsx b/src/views/friends/views/friends-list/FriendsRemoveConfirmationView.tsx similarity index 56% rename from src/views/friends/views/friends-remove-confirmation/FriendsRemoveConfirmationView.tsx rename to src/views/friends/views/friends-list/FriendsRemoveConfirmationView.tsx index f87db5c3..479a9396 100644 --- a/src/views/friends/views/friends-remove-confirmation/FriendsRemoveConfirmationView.tsx +++ b/src/views/friends/views/friends-list/FriendsRemoveConfirmationView.tsx @@ -1,6 +1,6 @@ import { FC } from 'react'; import { LocalizeText } from '../../../../api'; -import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../common'; +import { Button, Flex, NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../common'; interface FriendsRemoveConfirmationViewProps { @@ -15,14 +15,14 @@ export const FriendsRemoveConfirmationView: FC + - +
{ removeFriendsText }
-
- - -
+ + + +
); diff --git a/src/views/friends/views/friends-list/FriendsRoomInviteView.tsx b/src/views/friends/views/friends-list/FriendsRoomInviteView.tsx new file mode 100644 index 00000000..1716e104 --- /dev/null +++ b/src/views/friends/views/friends-list/FriendsRoomInviteView.tsx @@ -0,0 +1,32 @@ +import { FC, useState } from 'react'; +import { LocalizeText } from '../../../../api'; +import { Button, Flex, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../../common'; + +interface FriendsRoomInviteViewProps +{ + selectedFriendsIds: number[]; + onCloseClick: () => void; + sendRoomInvite: (message: string) => void; +} + +export const FriendsRoomInviteView: FC = props => +{ + const { selectedFriendsIds = null, onCloseClick = null, sendRoomInvite = null } = props; + + const [ roomInviteMessage, setRoomInviteMessage ] = useState(''); + + return ( + + + + { LocalizeText('friendlist.invite.summary', [ 'count' ], [ selectedFriendsIds.length.toString() ]) } + + { LocalizeText('friendlist.invite.note') } + + + + + + + ); +}; diff --git a/src/views/friends/views/friends-list/FriendsSearchView.tsx b/src/views/friends/views/friends-list/FriendsSearchView.tsx new file mode 100644 index 00000000..008b3eab --- /dev/null +++ b/src/views/friends/views/friends-list/FriendsSearchView.tsx @@ -0,0 +1,141 @@ +import { HabboSearchComposer, HabboSearchResultData, HabboSearchResultEvent } from '@nitrots/nitro-renderer'; +import { FC, useCallback, useEffect, useState } from 'react'; +import { LocalizeText, OpenMessengerChat, SendMessageComposer } from '../../../../api'; +import { Base, Column, Flex, NitroCardAccordionItemView, NitroCardAccordionSetView, NitroCardAccordionSetViewProps, Text, UserProfileIconView } from '../../../../common'; +import { BatchUpdates, UseMessageEventHook } from '../../../../hooks'; +import { useFriendsContext } from '../../FriendsContext'; + +interface FriendsSearchViewProps extends NitroCardAccordionSetViewProps +{ + +} + +export const FriendsSearchView: FC = props => +{ + const { ...rest } = props; + const [ searchValue, setSearchValue ] = useState(''); + const [ friendResults, setFriendResults ] = useState(null); + const [ otherResults, setOtherResults ] = useState(null); + const { canRequestFriend = null, requestFriend = null } = useFriendsContext(); + + const onHabboSearchResultEvent = useCallback((event: HabboSearchResultEvent) => + { + const parser = event.getParser(); + + BatchUpdates(() => + { + setFriendResults(parser.friends); + setOtherResults(parser.others); + }); + }, []); + + UseMessageEventHook(HabboSearchResultEvent, onHabboSearchResultEvent); + + useEffect(() => + { + if(!searchValue || !searchValue.length) return; + + const timeout = setTimeout(() => + { + if(!searchValue || !searchValue.length) return; + + SendMessageComposer(new HabboSearchComposer(searchValue)); + }, 500); + + return () => clearTimeout(timeout); + }, [ searchValue ]); + + return ( + + setSearchValue(event.target.value) } /> + + { friendResults && + <> + { (friendResults.length === 0) && + { LocalizeText('friendlist.search.nofriendsfound') } } + { (friendResults.length > 0) && + + { LocalizeText('friendlist.search.friendscaption', [ 'cnt' ], [ friendResults.length.toString() ]) } +
+ + { friendResults.map(result => + { + return ( + + + +
{ result.avatarName }
+
+ + { result.isAvatarOnline && + OpenMessengerChat(result.avatarId) } title={ LocalizeText('friendlist.tip.im') } /> } + +
+ ) + }) } +
+
} + } + { otherResults && + <> + { (otherResults.length === 0) && + { LocalizeText('friendlist.search.noothersfound') } } + { (otherResults.length > 0) && + + { LocalizeText('friendlist.search.otherscaption', [ 'cnt' ], [ otherResults.length.toString() ]) } +
+ + { otherResults.map(result => + { + return ( + + + +
{ result.avatarName }
+
+ + { canRequestFriend(result.avatarId) && + requestFriend(result.avatarId, result.avatarName) } title={ LocalizeText('friendlist.tip.addfriend') } /> } + +
+ ) + }) } +
+
} + } +
+ {/* + + { (friendResults.length > 0) && friendResults.map(result => + { + return ( + + + { result.avatarName } + + { result.isAvatarOnline && + OpenMessengerChat(result.avatarId) } title={ LocalizeText('friendlist.tip.im') } /> } + + + ); + }) } + + + { (otherResults.length > 0) && otherResults.map(result => + { + return ( + + + { result.avatarName } + + { canRequestFriend(result.avatarId) && + requestFriend(result.avatarId, result.avatarName) } title={ LocalizeText('friendlist.tip.addfriend') } /> } + + + ); + }) } + + */} +
+ ); +} diff --git a/src/views/friends/views/friends-list/friends-list-group/FriendsListGroupItemView.tsx b/src/views/friends/views/friends-list/friends-list-group/FriendsListGroupItemView.tsx new file mode 100644 index 00000000..d1978a46 --- /dev/null +++ b/src/views/friends/views/friends-list/friends-list-group/FriendsListGroupItemView.tsx @@ -0,0 +1,93 @@ +import { FollowFriendMessageComposer, SetRelationshipStatusComposer } from '@nitrots/nitro-renderer'; +import { FC, MouseEvent, useState } from 'react'; +import { LocalizeText, OpenMessengerChat, SendMessageComposer } from '../../../../../api'; +import { Base, Flex, NitroCardAccordionItemView, NitroCardAccordionItemViewProps, UserProfileIconView } from '../../../../../common'; +import { MessengerFriend } from '../../../common/MessengerFriend'; + +interface FriendsListGroupItemViewProps extends NitroCardAccordionItemViewProps +{ + friend: MessengerFriend; + selected?: boolean; + selectFriend: () => void; +} + +export const FriendsListGroupItemView: FC = props => +{ + const { friend = null, selected = false, selectFriend = null, children = null, ...rest } = props; + const [ isRelationshipOpen, setIsRelationshipOpen ] = useState(false); + + const followFriend = (event: MouseEvent) => + { + event.stopPropagation(); + + SendMessageComposer(new FollowFriendMessageComposer(friend.id)); + } + + const openMessengerChat = (event: MouseEvent) => + { + event.stopPropagation(); + + OpenMessengerChat(friend.id); + } + + const openRelationship = (event: MouseEvent) => + { + event.stopPropagation(); + + setIsRelationshipOpen(true); + } + + const updateRelationship = (event: MouseEvent, type: number) => + { + event.stopPropagation(); + + if(type !== friend.relationshipStatus) SendMessageComposer(new SetRelationshipStatusComposer(friend.id, type)); + + setIsRelationshipOpen(false); + } + + const getCurrentRelationshipName = () => + { + if(!friend) return 'none'; + + switch(friend.relationshipStatus) + { + case MessengerFriend.RELATIONSHIP_HEART: return 'heart'; + case MessengerFriend.RELATIONSHIP_SMILE: return 'smile'; + case MessengerFriend.RELATIONSHIP_BOBBA: return 'bobba'; + default: return 'none'; + } + } + + if(!friend) return null; + + return ( + + + event.stopPropagation() }> + + +
{ friend.name }
+
+ + { !isRelationshipOpen && + <> + { friend.followingAllowed && + } + { friend.online && + } + { (friend.id > 0) && + } + } + { isRelationshipOpen && + <> + updateRelationship(event, MessengerFriend.RELATIONSHIP_HEART) } /> + updateRelationship(event, MessengerFriend.RELATIONSHIP_SMILE) } /> + updateRelationship(event, MessengerFriend.RELATIONSHIP_BOBBA) } /> + updateRelationship(event, MessengerFriend.RELATIONSHIP_NONE) } /> + } + + { children } +
+ ); +} diff --git a/src/views/friends/views/friends-list/friends-list-group/FriendsListGroupView.tsx b/src/views/friends/views/friends-list/friends-list-group/FriendsListGroupView.tsx new file mode 100644 index 00000000..be5ef658 --- /dev/null +++ b/src/views/friends/views/friends-list/friends-list-group/FriendsListGroupView.tsx @@ -0,0 +1,24 @@ +import { FC } from 'react'; +import { MessengerFriend } from '../../../common/MessengerFriend'; +import { FriendsListGroupItemView } from './FriendsListGroupItemView'; + +interface FriendsListGroupViewProps +{ + list: MessengerFriend[]; + selectedFriendsIds: number[]; + selectFriend: (userId: number) => void; +} + +export const FriendsListGroupView: FC = props => +{ + const { list = null, selectedFriendsIds = null, selectFriend = null } = props; + + if(!list || !list.length) return null; + + return ( + <> + { list.map((item, index) => selectFriend(item.id) } />) } + + + ); +} diff --git a/src/views/friends/views/friends-list/friends-list-request/FriendsListRequestItemView.tsx b/src/views/friends/views/friends-list/friends-list-request/FriendsListRequestItemView.tsx new file mode 100644 index 00000000..57a33e52 --- /dev/null +++ b/src/views/friends/views/friends-list/friends-list-request/FriendsListRequestItemView.tsx @@ -0,0 +1,31 @@ +import { FC } from 'react'; +import { Base, Flex, NitroCardAccordionItemView, NitroCardAccordionItemViewProps, UserProfileIconView } from '../../../../../common'; +import { MessengerRequest } from '../../../common/MessengerRequest'; +import { useFriendsContext } from '../../../FriendsContext'; + +interface FriendsListRequestItemViewProps extends NitroCardAccordionItemViewProps +{ + request: MessengerRequest; +} + +export const FriendsListRequestItemView: FC = props => +{ + const { request = null, children = null, ...rest } = props; + const { acceptFriend = null, declineFriend = null } = useFriendsContext(); + + if(!request) return null; + + return ( + + + +
{ request.name }
+
+ + acceptFriend(request.requesterUserId) } /> + declineFriend(request.requesterUserId) } /> + + { children } +
+ ); +}; diff --git a/src/views/friends/views/friends-list/friends-list-request/FriendsListRequestView.tsx b/src/views/friends/views/friends-list/friends-list-request/FriendsListRequestView.tsx new file mode 100644 index 00000000..7b99131f --- /dev/null +++ b/src/views/friends/views/friends-list/friends-list-request/FriendsListRequestView.tsx @@ -0,0 +1,35 @@ +import { FC } from 'react'; +import { LocalizeText } from '../../../../../api'; +import { Button, Column, Flex, NitroCardAccordionSetView, NitroCardAccordionSetViewProps } from '../../../../../common'; +import { MessengerRequest } from '../../../common/MessengerRequest'; +import { useFriendsContext } from '../../../FriendsContext'; +import { FriendsListRequestItemView } from './FriendsListRequestItemView'; + +interface FriendsListRequestViewProps extends NitroCardAccordionSetViewProps +{ + requests: MessengerRequest[]; +} + +export const FriendsListRequestView: FC = props => +{ + const { requests = [], children = null, ...rest } = props; + const { declineFriend = null } = useFriendsContext(); + + if(!requests.length) return null; + + return ( + + + + { requests.map((request, index) => ) } + + + + + + { children } + + ); +} diff --git a/src/views/friends/views/friends-request/FriendsRequestItemView.tsx b/src/views/friends/views/friends-request/FriendsRequestItemView.tsx deleted file mode 100644 index ffb39e4c..00000000 --- a/src/views/friends/views/friends-request/FriendsRequestItemView.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { FC } from 'react'; -import { Base, Flex, NitroCardAccordionItemView, UserProfileIconView } from '../../../../common'; -import { MessengerRequest } from '../../common/MessengerRequest'; -import { useFriendsContext } from '../../FriendsContext'; - -interface FriendsRequestItemViewProps -{ - request: MessengerRequest; -} - -export const FriendsRequestItemView: FC = props => -{ - const { request = null } = props; - const { acceptFriend = null, declineFriend = null } = useFriendsContext(); - - if(!request) return null; - - return ( - - - { request.name } - - acceptFriend(request.requesterUserId) } /> - declineFriend(request.requesterUserId) } /> - - - ); -}; diff --git a/src/views/friends/views/friends-request/FriendsRequestView.tsx b/src/views/friends/views/friends-request/FriendsRequestView.tsx deleted file mode 100644 index 2fa00536..00000000 --- a/src/views/friends/views/friends-request/FriendsRequestView.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import { FC } from 'react'; -import { LocalizeText } from '../../../../api'; -import { Button, Flex, NitroCardAccordionSetView } from '../../../../common'; -import { MessengerRequest } from '../../common/MessengerRequest'; -import { useFriendsContext } from '../../FriendsContext'; -import { FriendsRequestItemView } from './FriendsRequestItemView'; - -interface FriendsRequestViewProps -{ - requests: MessengerRequest[]; -} - -export const FriendsRequestView: FC = props => -{ - const { requests = [] } = props; - const { declineFriend = null } = useFriendsContext(); - - if(!requests.length) return null; - - return ( - - { requests.map((request, index) => - { - return - }) } - - - - - ); -} diff --git a/src/views/friends/views/friends-room-invite/FriendsRoomInviteView.tsx b/src/views/friends/views/friends-room-invite/FriendsRoomInviteView.tsx deleted file mode 100644 index a3a80efb..00000000 --- a/src/views/friends/views/friends-room-invite/FriendsRoomInviteView.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import { FC, useState } from 'react'; -import { LocalizeText } from '../../../../api'; -import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../common'; - -interface FriendsRoomInviteViewProps -{ - selectedFriendsIds: number[]; - onCloseClick: () => void; - sendRoomInvite: (message: string) => void; -} - -export const FriendsRoomInviteView: FC = props => -{ - const { selectedFriendsIds = null, onCloseClick = null, sendRoomInvite = null } = props; - - const [ roomInviteMessage, setRoomInviteMessage ] = useState(''); - - return ( - - - - { LocalizeText('friendlist.invite.summary', ['count'], [selectedFriendsIds.length.toString()]) } - -
{ LocalizeText('friendlist.invite.note') }
-
- - -
-
-
- ); -}; diff --git a/src/views/friends/views/friends-search/FriendsSearchView.tsx b/src/views/friends/views/friends-search/FriendsSearchView.tsx deleted file mode 100644 index 886dda13..00000000 --- a/src/views/friends/views/friends-search/FriendsSearchView.tsx +++ /dev/null @@ -1,79 +0,0 @@ -import { HabboSearchComposer, HabboSearchResultData, HabboSearchResultEvent } from '@nitrots/nitro-renderer'; -import { FC, useCallback, useEffect, useState } from 'react'; -import { LocalizeText, OpenMessengerChat, SendMessageComposer } from '../../../../api'; -import { Base, Flex, NitroCardAccordionItemView, NitroCardAccordionSetView, NitroCardAccordionView, UserProfileIconView } from '../../../../common'; -import { BatchUpdates, UseMessageEventHook } from '../../../../hooks'; -import { useFriendsContext } from '../../FriendsContext'; - -export const FriendsSearchView: FC<{}> = props => -{ - const [ searchValue, setSearchValue ] = useState(''); - const [ friendResults, setFriendResults ] = useState([]); - const [ otherResults, setOtherResults ] = useState([]); - const { canRequestFriend = null, requestFriend = null } = useFriendsContext(); - - const onHabboSearchResultEvent = useCallback((event: HabboSearchResultEvent) => - { - const parser = event.getParser(); - - BatchUpdates(() => - { - setFriendResults(parser.friends); - setOtherResults(parser.others); - }); - }, []); - - UseMessageEventHook(HabboSearchResultEvent, onHabboSearchResultEvent); - - useEffect(() => - { - if(!searchValue || !searchValue.length) return; - - const timeout = setTimeout(() => - { - if(!searchValue || !searchValue.length) return; - - SendMessageComposer(new HabboSearchComposer(searchValue)); - }, 500); - - return () => clearTimeout(timeout); - }, [ searchValue ]); - - return ( - <> - setSearchValue(event.target.value) } /> - - - { (friendResults.length > 0) && friendResults.map(result => - { - return ( - - - { result.avatarName } - - { result.isAvatarOnline && - OpenMessengerChat(result.avatarId) } title={ LocalizeText('friendlist.tip.im') } /> } - - - ); - }) } - - - { (otherResults.length > 0) && otherResults.map(result => - { - return ( - - - { result.avatarName } - - { canRequestFriend(result.avatarId) && - requestFriend(result.avatarId, result.avatarName) } title={ LocalizeText('friendlist.tip.addfriend') } /> } - - - ); - }) } - - - - ); -}