mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-26 07:30:51 +01:00
add listener for ExtendedProfileChangedMessageEvent packet (#112)
This commit is contained in:
parent
afec012eb6
commit
f4c7c3cf1a
@ -1,4 +1,4 @@
|
|||||||
import { RelationshipStatusInfoEvent, RelationshipStatusInfoMessageParser, RoomEngineObjectEvent, RoomObjectCategory, RoomObjectType, UserCurrentBadgesComposer, UserCurrentBadgesEvent, UserProfileEvent, UserProfileParser, UserRelationshipsComposer } from '@nitrots/nitro-renderer';
|
import { ExtendedProfileChangedMessageEvent, RelationshipStatusInfoEvent, RelationshipStatusInfoMessageParser, RoomEngineObjectEvent, RoomObjectCategory, RoomObjectType, UserCurrentBadgesComposer, UserCurrentBadgesEvent, UserProfileEvent, UserProfileParser, UserRelationshipsComposer } from '@nitrots/nitro-renderer';
|
||||||
import { FC, useState } from 'react';
|
import { FC, useState } from 'react';
|
||||||
import { CreateLinkEvent, GetRoomSession, GetSessionDataManager, GetUserProfile, LocalizeText, SendMessageComposer } from '../../api';
|
import { CreateLinkEvent, GetRoomSession, GetSessionDataManager, GetUserProfile, LocalizeText, SendMessageComposer } from '../../api';
|
||||||
import { Column, Flex, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../common';
|
import { Column, Flex, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../common';
|
||||||
@ -24,7 +24,7 @@ export const UserProfileView: FC<{}> = props =>
|
|||||||
const onLeaveGroup = () =>
|
const onLeaveGroup = () =>
|
||||||
{
|
{
|
||||||
if(!userProfile || (userProfile.id !== GetSessionDataManager().userId)) return;
|
if(!userProfile || (userProfile.id !== GetSessionDataManager().userId)) return;
|
||||||
|
|
||||||
GetUserProfile(userProfile.id);
|
GetUserProfile(userProfile.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ export const UserProfileView: FC<{}> = props =>
|
|||||||
const parser = event.getParser();
|
const parser = event.getParser();
|
||||||
|
|
||||||
if(!userProfile || (parser.userId !== userProfile.id)) return;
|
if(!userProfile || (parser.userId !== userProfile.id)) return;
|
||||||
|
|
||||||
setUserBadges(parser.badges);
|
setUserBadges(parser.badges);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ export const UserProfileView: FC<{}> = props =>
|
|||||||
const parser = event.getParser();
|
const parser = event.getParser();
|
||||||
|
|
||||||
if(!userProfile || (parser.userId !== userProfile.id)) return;
|
if(!userProfile || (parser.userId !== userProfile.id)) return;
|
||||||
|
|
||||||
setUserRelationships(parser);
|
setUserRelationships(parser);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ export const UserProfileView: FC<{}> = props =>
|
|||||||
const parser = event.getParser();
|
const parser = event.getParser();
|
||||||
|
|
||||||
let isSameProfile = false;
|
let isSameProfile = false;
|
||||||
|
|
||||||
setUserProfile(prevValue =>
|
setUserProfile(prevValue =>
|
||||||
{
|
{
|
||||||
if(prevValue && prevValue.id) isSameProfile = (prevValue.id === parser.id);
|
if(prevValue && prevValue.id) isSameProfile = (prevValue.id === parser.id);
|
||||||
@ -69,10 +69,19 @@ export const UserProfileView: FC<{}> = props =>
|
|||||||
SendMessageComposer(new UserRelationshipsComposer(parser.id));
|
SendMessageComposer(new UserRelationshipsComposer(parser.id));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useMessageEvent<ExtendedProfileChangedMessageEvent>(ExtendedProfileChangedMessageEvent, event =>
|
||||||
|
{
|
||||||
|
const parser = event.getParser();
|
||||||
|
|
||||||
|
if(parser.userId != userProfile?.id) return;
|
||||||
|
|
||||||
|
GetUserProfile(parser.userId);
|
||||||
|
});
|
||||||
|
|
||||||
useRoomEngineEvent<RoomEngineObjectEvent>(RoomEngineObjectEvent.SELECTED, event =>
|
useRoomEngineEvent<RoomEngineObjectEvent>(RoomEngineObjectEvent.SELECTED, event =>
|
||||||
{
|
{
|
||||||
if(!userProfile) return;
|
if(!userProfile) return;
|
||||||
|
|
||||||
if(event.category !== RoomObjectCategory.UNIT) return;
|
if(event.category !== RoomObjectCategory.UNIT) return;
|
||||||
|
|
||||||
const userData = GetRoomSession().userDataManager.getUserDataByIndex(event.objectId);
|
const userData = GetRoomSession().userDataManager.getUserDataByIndex(event.objectId);
|
||||||
|
Loading…
Reference in New Issue
Block a user