mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-30 00:50:50 +01:00
Add MessengerSettings to FriendList
This commit is contained in:
parent
4e4a3fb14f
commit
1f562d01b1
@ -1,18 +1,27 @@
|
|||||||
|
import { GetFriendRequestsComposer, MessengerInitEvent } from 'nitro-renderer';
|
||||||
|
import { useCallback } from 'react';
|
||||||
|
import { CreateMessageHook, SendMessageHook } from '../../hooks/messages/message-event';
|
||||||
import { FriendListMessageHandlerProps } from './FriendListMessageHandler.types';
|
import { FriendListMessageHandlerProps } from './FriendListMessageHandler.types';
|
||||||
|
import { MessengerSettings } from './utils/MessengerSettings';
|
||||||
|
|
||||||
export function FriendListMessageHandler(props: FriendListMessageHandlerProps): JSX.Element
|
export function FriendListMessageHandler(props: FriendListMessageHandlerProps): JSX.Element
|
||||||
{
|
{
|
||||||
const { } = props;
|
const { setMessengerSettings = null } = props;
|
||||||
|
|
||||||
/*const onUserInfoEvent = useCallback((event: UserInfoEvent) =>
|
const onMessengerInitEvent = useCallback((event: MessengerInitEvent) =>
|
||||||
{
|
{
|
||||||
//const parser = event.getParser();
|
const parser = event.getParser();
|
||||||
|
|
||||||
SendMessageHook(new NavigatorCategoriesComposer());
|
setMessengerSettings(new MessengerSettings(
|
||||||
SendMessageHook(new NavigatorSettingsComposer());
|
parser.userFriendLimit,
|
||||||
}, []);*/
|
parser.normalFriendLimit,
|
||||||
|
parser.extendedFriendLimit,
|
||||||
|
parser.categories));
|
||||||
|
|
||||||
//CreateMessageHook(UserInfoEvent, onUserInfoEvent);
|
SendMessageHook(new GetFriendRequestsComposer());
|
||||||
|
}, [ setMessengerSettings ]);
|
||||||
|
|
||||||
|
CreateMessageHook(MessengerInitEvent, onMessengerInitEvent);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,6 @@
|
|||||||
|
import { MessengerSettings } from './utils/MessengerSettings';
|
||||||
|
|
||||||
export interface FriendListMessageHandlerProps
|
export interface FriendListMessageHandlerProps
|
||||||
{}
|
{
|
||||||
|
setMessengerSettings: (messengerSettings: MessengerSettings) => void;
|
||||||
|
}
|
||||||
|
@ -1,26 +1,24 @@
|
|||||||
|
import { MessengerInitComposer } from 'nitro-renderer';
|
||||||
import React, { FC, useCallback, useEffect, useState } from 'react';
|
import React, { FC, useCallback, useEffect, useState } from 'react';
|
||||||
import { FriendListEvent } from '../../events';
|
import { FriendListEvent } from '../../events';
|
||||||
import { DraggableWindow } from '../../hooks/draggable-window/DraggableWindow';
|
import { DraggableWindow } from '../../hooks/draggable-window/DraggableWindow';
|
||||||
import { useUiEvent } from '../../hooks/events/ui/ui-event';
|
import { useUiEvent } from '../../hooks/events/ui/ui-event';
|
||||||
|
import { SendMessageHook } from '../../hooks/messages/message-event';
|
||||||
import { LocalizeText } from '../../utils/LocalizeText';
|
import { LocalizeText } from '../../utils/LocalizeText';
|
||||||
import { FriendListMessageHandler } from './FriendListMessageHandler';
|
import { FriendListMessageHandler } from './FriendListMessageHandler';
|
||||||
import { FriendListTabs, FriendListViewProps, IFriendListContext } from './FriendListView.types';
|
import { FriendListTabs, FriendListViewProps, IFriendListContext } from './FriendListView.types';
|
||||||
import { FriendListTabsContentView } from './tabs-content/FriendListTabsContentView';
|
import { FriendListTabsContentView } from './tabs-content/FriendListTabsContentView';
|
||||||
import { FriendListTabsSelectorView } from './tabs-selector/FriendListTabsSelectorView';
|
import { FriendListTabsSelectorView } from './tabs-selector/FriendListTabsSelectorView';
|
||||||
|
import { MessengerSettings } from './utils/MessengerSettings';
|
||||||
|
|
||||||
export const FriendListContext = React.createContext<IFriendListContext>(null);
|
export const FriendListContext = React.createContext<IFriendListContext>(null);
|
||||||
|
|
||||||
export const FriendListView: FC<FriendListViewProps> = props =>
|
export const FriendListView: FC<FriendListViewProps> = props =>
|
||||||
{
|
{
|
||||||
const [ isVisible, setIsVisible ] = useState(false);
|
const [ isVisible, setIsVisible ] = useState(false);
|
||||||
const [ currentTab, setCurrentTab ] = useState<string>(null);
|
const [ currentTab, setCurrentTab ] = useState<string>(null);
|
||||||
const [ tabs, setTabs ] = useState<string[]>([
|
const [ tabs, setTabs ] = useState<string[]>([ FriendListTabs.FRIENDS, FriendListTabs.REQUESTS, FriendListTabs.SEARCH ]);
|
||||||
FriendListTabs.FRIENDS, FriendListTabs.REQUESTS, FriendListTabs.SEARCH
|
const [ messengerSettings, setMessengerSettings ] = useState<MessengerSettings>(null);
|
||||||
]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setCurrentTab(tabs[0]);
|
|
||||||
}, [ tabs ]);
|
|
||||||
|
|
||||||
const onFriendListEvent = useCallback((event: FriendListEvent) =>
|
const onFriendListEvent = useCallback((event: FriendListEvent) =>
|
||||||
{
|
{
|
||||||
@ -38,6 +36,23 @@ export const FriendListView: FC<FriendListViewProps> = props =>
|
|||||||
useUiEvent(FriendListEvent.SHOW_FRIEND_LIST, onFriendListEvent);
|
useUiEvent(FriendListEvent.SHOW_FRIEND_LIST, onFriendListEvent);
|
||||||
useUiEvent(FriendListEvent.TOGGLE_FRIEND_LIST, onFriendListEvent);
|
useUiEvent(FriendListEvent.TOGGLE_FRIEND_LIST, onFriendListEvent);
|
||||||
|
|
||||||
|
useEffect(() =>
|
||||||
|
{
|
||||||
|
setCurrentTab(tabs[0]);
|
||||||
|
}, [ tabs ]);
|
||||||
|
|
||||||
|
useEffect(() =>
|
||||||
|
{
|
||||||
|
if(!messengerSettings) return;
|
||||||
|
|
||||||
|
console.log(messengerSettings);
|
||||||
|
}, [ messengerSettings ]);
|
||||||
|
|
||||||
|
useEffect(() =>
|
||||||
|
{
|
||||||
|
SendMessageHook(new MessengerInitComposer());
|
||||||
|
}, []);
|
||||||
|
|
||||||
function hideFriendList(): void
|
function hideFriendList(): void
|
||||||
{
|
{
|
||||||
setIsVisible(false);
|
setIsVisible(false);
|
||||||
@ -45,7 +60,7 @@ export const FriendListView: FC<FriendListViewProps> = props =>
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<FriendListContext.Provider value={{ currentTab: currentTab, onSetCurrentTab: setCurrentTab }}>
|
<FriendListContext.Provider value={{ currentTab: currentTab, onSetCurrentTab: setCurrentTab }}>
|
||||||
<FriendListMessageHandler />
|
<FriendListMessageHandler setMessengerSettings={ setMessengerSettings } />
|
||||||
{ isVisible && <DraggableWindow handle=".drag-handler">
|
{ isVisible && <DraggableWindow handle=".drag-handler">
|
||||||
<div className="nitro-friend-list d-flex flex-column bg-primary border border-black shadow rounded">
|
<div className="nitro-friend-list d-flex flex-column bg-primary border border-black shadow rounded">
|
||||||
<div className="drag-handler d-flex justify-content-between align-items-center px-3 pt-3">
|
<div className="drag-handler d-flex justify-content-between align-items-center px-3 pt-3">
|
||||||
|
10
src/views/friend-list/utils/MessengerSettings.ts
Normal file
10
src/views/friend-list/utils/MessengerSettings.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { FriendCategoryData } from 'nitro-renderer';
|
||||||
|
|
||||||
|
export class MessengerSettings
|
||||||
|
{
|
||||||
|
constructor(
|
||||||
|
public userFriendLimit: number = 0,
|
||||||
|
public normalFriendLimit: number = 0,
|
||||||
|
public extendedFriendLimit: number = 0,
|
||||||
|
public categories: FriendCategoryData[] = []) {}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user