mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-23 06:40:50 +01:00
Update friend list
This commit is contained in:
parent
c7fe32411f
commit
7893de3a34
20
src/events/friend-list/FriendListSendFriendRequestEvent.ts
Normal file
20
src/events/friend-list/FriendListSendFriendRequestEvent.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { FriendListEvent } from './FriendListEvent';
|
||||
|
||||
export class FriendListSendFriendRequestEvent extends FriendListEvent
|
||||
{
|
||||
public static SEND_FRIEND_REQUEST: string = 'FLSFRE_SEND_FRIEND_REQUEST';
|
||||
|
||||
private _userId: number;
|
||||
|
||||
constructor(userId: number)
|
||||
{
|
||||
super(FriendListSendFriendRequestEvent.SEND_FRIEND_REQUEST);
|
||||
|
||||
this._userId = userId;
|
||||
}
|
||||
|
||||
public get userId(): number
|
||||
{
|
||||
return this._userId;
|
||||
}
|
||||
}
|
@ -1,8 +1,9 @@
|
||||
import { MessengerInitComposer, RoomEngineObjectEvent, RoomObjectCategory } from 'nitro-renderer';
|
||||
import { MessengerInitComposer, RoomEngineObjectEvent, RoomObjectCategory, RoomObjectUserType } from 'nitro-renderer';
|
||||
import React, { FC, useCallback, useEffect, useReducer, useState } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { GetRoomSession } from '../../api';
|
||||
import { FriendEnteredRoomEvent, FriendListEvent } from '../../events';
|
||||
import { FriendListSendFriendRequestEvent } from '../../events/friend-list/FriendListSendFriendRequestEvent';
|
||||
import { useRoomEngineEvent } from '../../hooks/events';
|
||||
import { dispatchUiEvent, useUiEvent } from '../../hooks/events/ui/ui-event';
|
||||
import { SendMessageHook } from '../../hooks/messages/message-event';
|
||||
@ -32,11 +33,15 @@ export const FriendListView: FC<FriendListViewProps> = props =>
|
||||
case FriendListEvent.TOGGLE_FRIEND_LIST:
|
||||
setIsVisible(value => !value);
|
||||
return;
|
||||
case FriendListSendFriendRequestEvent.SEND_FRIEND_REQUEST:
|
||||
const requestEvent = (event as FriendListSendFriendRequestEvent);
|
||||
return;
|
||||
}
|
||||
}, []);
|
||||
|
||||
useUiEvent(FriendListEvent.SHOW_FRIEND_LIST, onFriendListEvent);
|
||||
useUiEvent(FriendListEvent.TOGGLE_FRIEND_LIST, onFriendListEvent);
|
||||
useUiEvent(FriendListSendFriendRequestEvent.SEND_FRIEND_REQUEST, onFriendListEvent);
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
@ -60,7 +65,7 @@ export const FriendListView: FC<FriendListViewProps> = props =>
|
||||
|
||||
const userData = roomSession.userDataManager.getUserDataByIndex(event.objectId);
|
||||
|
||||
if(!userData) return;
|
||||
if(!userData || (userData.type !== RoomObjectUserType.getTypeNumber(RoomObjectUserType.USER))) return;
|
||||
|
||||
const friend = friendListState.friends.find(friend =>
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { FollowFriendComposer, MouseEventType } from 'nitro-renderer';
|
||||
import { FC, useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { GetConnection } from '../../../../api';
|
||||
import { SendMessageHook } from '../../../../hooks/messages';
|
||||
import { LocalizeText } from '../../../../utils/LocalizeText';
|
||||
import { AvatarImageView } from '../../../shared/avatar-image/AvatarImageView';
|
||||
import { FriendBarItemViewProps } from './FriendBarItemView.types';
|
||||
@ -13,7 +13,7 @@ export const FriendBarItemView: FC<FriendBarItemViewProps> = props =>
|
||||
|
||||
const followFriend = useCallback(() =>
|
||||
{
|
||||
GetConnection().send(new FollowFriendComposer(friend.id));
|
||||
SendMessageHook(new FollowFriendComposer(friend.id));
|
||||
}, [ friend ]);
|
||||
|
||||
const onClick = useCallback((event: MouseEvent) =>
|
||||
|
Loading…
Reference in New Issue
Block a user