mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-26 23:50:52 +01:00
Messenger updates
This commit is contained in:
parent
4e56447adc
commit
6721efcec5
@ -7,7 +7,7 @@ import { FriendListSendFriendRequestEvent } from '../../events/friend-list/Frien
|
|||||||
import { useRoomEngineEvent } from '../../hooks/events';
|
import { useRoomEngineEvent } from '../../hooks/events';
|
||||||
import { dispatchUiEvent, useUiEvent } from '../../hooks/events/ui/ui-event';
|
import { dispatchUiEvent, useUiEvent } from '../../hooks/events/ui/ui-event';
|
||||||
import { SendMessageHook } from '../../hooks/messages/message-event';
|
import { SendMessageHook } from '../../hooks/messages/message-event';
|
||||||
import { NitroCardAccordionItemView, NitroCardAccordionView, NitroCardHeaderView, NitroCardView } from '../../layout';
|
import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../layout';
|
||||||
import { LocalizeText } from '../../utils/LocalizeText';
|
import { LocalizeText } from '../../utils/LocalizeText';
|
||||||
import { FriendListContextProvider } from './context/FriendListContext';
|
import { FriendListContextProvider } from './context/FriendListContext';
|
||||||
import { FriendListMessageHandler } from './FriendListMessageHandler';
|
import { FriendListMessageHandler } from './FriendListMessageHandler';
|
||||||
@ -43,18 +43,6 @@ export const FriendListView: FC<FriendListViewProps> = props =>
|
|||||||
useUiEvent(FriendListEvent.TOGGLE_FRIEND_LIST, onFriendListEvent);
|
useUiEvent(FriendListEvent.TOGGLE_FRIEND_LIST, onFriendListEvent);
|
||||||
useUiEvent(FriendListSendFriendRequestEvent.SEND_FRIEND_REQUEST, onFriendListEvent);
|
useUiEvent(FriendListSendFriendRequestEvent.SEND_FRIEND_REQUEST, onFriendListEvent);
|
||||||
|
|
||||||
useEffect(() =>
|
|
||||||
{
|
|
||||||
if(!settings) return;
|
|
||||||
|
|
||||||
setIsReady(true);
|
|
||||||
}, [ settings ]);
|
|
||||||
|
|
||||||
useEffect(() =>
|
|
||||||
{
|
|
||||||
SendMessageHook(new MessengerInitComposer());
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const onRoomEngineObjectEvent = useCallback((event: RoomEngineObjectEvent) =>
|
const onRoomEngineObjectEvent = useCallback((event: RoomEngineObjectEvent) =>
|
||||||
{
|
{
|
||||||
const roomSession = GetRoomSession();
|
const roomSession = GetRoomSession();
|
||||||
@ -79,6 +67,18 @@ export const FriendListView: FC<FriendListViewProps> = props =>
|
|||||||
|
|
||||||
useRoomEngineEvent(RoomEngineObjectEvent.ADDED, onRoomEngineObjectEvent);
|
useRoomEngineEvent(RoomEngineObjectEvent.ADDED, onRoomEngineObjectEvent);
|
||||||
|
|
||||||
|
useEffect(() =>
|
||||||
|
{
|
||||||
|
if(!settings) return;
|
||||||
|
|
||||||
|
setIsReady(true);
|
||||||
|
}, [ settings ]);
|
||||||
|
|
||||||
|
useEffect(() =>
|
||||||
|
{
|
||||||
|
SendMessageHook(new MessengerInitComposer());
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FriendListContextProvider value={ { friendListState, dispatchFriendListState } }>
|
<FriendListContextProvider value={ { friendListState, dispatchFriendListState } }>
|
||||||
<FriendListMessageHandler />
|
<FriendListMessageHandler />
|
||||||
@ -86,17 +86,14 @@ export const FriendListView: FC<FriendListViewProps> = props =>
|
|||||||
{ isVisible &&
|
{ isVisible &&
|
||||||
<NitroCardView className="nitro-friend-list">
|
<NitroCardView className="nitro-friend-list">
|
||||||
<NitroCardHeaderView headerText={ LocalizeText('friendlist.friends') } onCloseClick={ event => setIsVisible(false) } />
|
<NitroCardHeaderView headerText={ LocalizeText('friendlist.friends') } onCloseClick={ event => setIsVisible(false) } />
|
||||||
<NitroCardAccordionView>
|
<NitroCardContentView>
|
||||||
<NitroCardAccordionItemView headerText="Friends" contentClassName="ps-3">
|
<div className="text-black fw-bold">{ LocalizeText('friendlist.search.friendscaption') }</div>
|
||||||
<FriendListFriendsView />
|
<FriendListFriendsView online={ true } />
|
||||||
</NitroCardAccordionItemView>
|
<div className="text-black fw-bold">{ LocalizeText('friendlist.search.friendscaption') }</div>
|
||||||
<NitroCardAccordionItemView headerText="Friend Requests" contentClassName="ps-3">
|
<FriendListFriendsView online={ true } />
|
||||||
abc
|
<div className="text-black fw-bold">{ LocalizeText('friendlist.friends.offlinecaption') }</div>
|
||||||
</NitroCardAccordionItemView>
|
<FriendListFriendsView online={ false } />
|
||||||
<NitroCardAccordionItemView headerText="Search" contentClassName="ps-3">
|
</NitroCardContentView>
|
||||||
abc
|
|
||||||
</NitroCardAccordionItemView>
|
|
||||||
</NitroCardAccordionView>
|
|
||||||
</NitroCardView> }
|
</NitroCardView> }
|
||||||
</FriendListContextProvider>
|
</FriendListContextProvider>
|
||||||
);
|
);
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
import { FC } from 'react';
|
||||||
|
import { FriendListFriendsItemViewProps } from './FriendListFriendsItemView.types';
|
||||||
|
|
||||||
|
export const FriendListFriendsItemView: FC<FriendListFriendsItemViewProps> = props =>
|
||||||
|
{
|
||||||
|
const { friend = null } = props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="d-flex">
|
||||||
|
<div className="text-black">{ friend.name }</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
import { MessengerFriend } from '../../common/MessengerFriend';
|
||||||
|
|
||||||
|
export interface FriendListFriendsItemViewProps
|
||||||
|
{
|
||||||
|
friend: MessengerFriend;
|
||||||
|
}
|
@ -1,36 +1,35 @@
|
|||||||
import { FC, useState } from 'react';
|
import { FC, useMemo } from 'react';
|
||||||
import { NitroCardAccordionItemView } from '../../../../layout/card/accordion/item/NitroCardAccordionItemView';
|
|
||||||
import { NitroCardAccordionView } from '../../../../layout/card/accordion/NitroCardAccordionView';
|
|
||||||
import { useFriendListContext } from '../../context/FriendListContext';
|
import { useFriendListContext } from '../../context/FriendListContext';
|
||||||
|
import { FriendListFriendsItemView } from '../friends-item/FriendListFriendsItemView';
|
||||||
import { FriendListFriendsViewProps } from './FriendListFriendsView.types';
|
import { FriendListFriendsViewProps } from './FriendListFriendsView.types';
|
||||||
|
|
||||||
export const FriendListFriendsView: FC<FriendListFriendsViewProps> = props =>
|
export const FriendListFriendsView: FC<FriendListFriendsViewProps> = props =>
|
||||||
{
|
{
|
||||||
|
const { online = true } = props;
|
||||||
const { friendListState = null } = useFriendListContext();
|
const { friendListState = null } = useFriendListContext();
|
||||||
|
const { friends = null } = friendListState;
|
||||||
|
|
||||||
const [ isOnlineFriendsExtended, setIsOnlineFriendsExtended ] = useState(false);
|
const getFriendElements = useMemo(() =>
|
||||||
const [ isOfflineFriendsExtended, setIsOfflineFriendsExtended ] = useState(false);
|
|
||||||
|
|
||||||
function toggleOnlineFriends(): void
|
|
||||||
{
|
{
|
||||||
setIsOnlineFriendsExtended(value => !value);
|
if(!friends || !friends.length) return null;
|
||||||
|
|
||||||
|
const elements: JSX.Element[] = [];
|
||||||
|
|
||||||
|
for(const friend of friends)
|
||||||
|
{
|
||||||
|
if(!friend || (friend.online !== online)) continue;
|
||||||
|
|
||||||
|
elements.push(<FriendListFriendsItemView key={ friend.id } friend={ friend } />)
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleOfflineFriends(): void
|
console.log(elements);
|
||||||
{
|
|
||||||
setIsOfflineFriendsExtended(value => !value);
|
return elements;
|
||||||
}
|
}, [ friends, online ]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="d-flex flex-column">
|
||||||
<NitroCardAccordionView>
|
{ getFriendElements }
|
||||||
<NitroCardAccordionItemView headerText="Friends (0)">
|
</div>
|
||||||
abc
|
|
||||||
</NitroCardAccordionItemView>
|
|
||||||
<NitroCardAccordionItemView headerText="Offline Friends (0)">
|
|
||||||
abc
|
|
||||||
</NitroCardAccordionItemView>
|
|
||||||
</NitroCardAccordionView>
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,4 @@
|
|||||||
export interface FriendListFriendsViewProps
|
export interface FriendListFriendsViewProps
|
||||||
{}
|
{
|
||||||
|
online?: boolean;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user