import { MessengerInitComposer } from 'nitro-renderer'; import React, { FC, useCallback, useEffect, useState } from 'react'; import { FriendListEvent } from '../../events'; import { DraggableWindow } from '../../hooks/draggable-window/DraggableWindow'; import { useUiEvent } from '../../hooks/events/ui/ui-event'; import { SendMessageHook } from '../../hooks/messages/message-event'; import { LocalizeText } from '../../utils/LocalizeText'; import { FriendListMessageHandler } from './FriendListMessageHandler'; import { FriendListTabs, FriendListViewProps, IFriendListContext } from './FriendListView.types'; import { FriendListTabsContentView } from './tabs-content/FriendListTabsContentView'; import { FriendListTabsSelectorView } from './tabs-selector/FriendListTabsSelectorView'; import { MessengerSettings } from './utils/MessengerSettings'; export const FriendListContext = React.createContext(null); export const FriendListView: FC = props => { const [ isVisible, setIsVisible ] = useState(false); const [ currentTab, setCurrentTab ] = useState(null); const [ tabs, setTabs ] = useState([ FriendListTabs.FRIENDS, FriendListTabs.REQUESTS, FriendListTabs.SEARCH ]); const [ messengerSettings, setMessengerSettings ] = useState(null); const onFriendListEvent = useCallback((event: FriendListEvent) => { switch(event.type) { case FriendListEvent.SHOW_FRIEND_LIST: setIsVisible(true); return; case FriendListEvent.TOGGLE_FRIEND_LIST: setIsVisible(value => !value); return; } }, []); useUiEvent(FriendListEvent.SHOW_FRIEND_LIST, onFriendListEvent); useUiEvent(FriendListEvent.TOGGLE_FRIEND_LIST, onFriendListEvent); useEffect(() => { setCurrentTab(tabs[0]); }, [ tabs ]); useEffect(() => { if(!messengerSettings) return; }, [ messengerSettings ]); useEffect(() => { SendMessageHook(new MessengerInitComposer()); }, []); function hideFriendList(): void { setIsVisible(false); } return ( { isVisible &&
{ LocalizeText('friendlist.friends') }
}
); }