Skip to content

Commit

Permalink
Merge pull request #33 from AgoraIO-Community/feature/2.9.40-special.1
Browse files Browse the repository at this point in the history
fix 2.9.40-special.1 bugs
  • Loading branch information
FocusOnWrittingBug authored Aug 8, 2024
2 parents 250a48b + 0f7ad65 commit 04b5453
Show file tree
Hide file tree
Showing 17 changed files with 333 additions and 179 deletions.
81 changes: 48 additions & 33 deletions src/common/im/wrapper/agora-chat-room-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { convertHXMessage } from './utils';
import dayjs from 'dayjs';
import { FcrChatRoomItem } from './agora-chat-room-item';
import { AgoraIM } from '.';
import { join } from 'lodash';
import { runInAction } from 'mobx';

type AgoraChatLog = {
level: Lowercase<AgoraChat.DefaultLevel>;
logs: [string, unknown];
Expand Down Expand Up @@ -258,11 +259,11 @@ export class FcrChatRoomManager {
break;
case 'memberAbsence':
await this.listenerUserLeft(msg.from,msg.id)
this.emitEventsInfo(AgoraIMEvents.UserLeft, msg.from, msg.id);
this.emitEventsInfo(AgoraIMEvents.UserLeft, null, msg.id);
this.emitEventsInfo(AgoraIMEvents.UserListUpdated, msg.from, msg.id);
//非主房间要通知下主房间,因为主房间包含所有
if(this._defaultChatRoomeId !== msg.id){
this.emitEventsInfo(AgoraIMEvents.UserJoined, msg.from, this._defaultChatRoomeId);
this.emitEventsInfo(AgoraIMEvents.UserJoined, null, this._defaultChatRoomeId);
this.emitEventsInfo(AgoraIMEvents.UserListUpdated, msg.from, this._defaultChatRoomeId);
}
break;
Expand Down Expand Up @@ -334,25 +335,27 @@ export class FcrChatRoomManager {
* @param value 值
*/
private emitEventsInfo(events: AgoraIMEvents, data?: any, toChatRoomId?: string | null) {
if (toChatRoomId != null) {
this._chatRoomItemMap.forEach((value, key) => {
if (toChatRoomId === key) {
runInAction(()=>{
if (toChatRoomId != null) {
this._chatRoomItemMap.forEach((value, key) => {
if (toChatRoomId === key) {
if (data != null) {
value.emit(events, data);
} else {
value.emit(events);
}
}
});
} else {
this._chatRoomItemMap.forEach((value) => {
if (data != null) {
value.emit(events, data);
} else {
value.emit(events);
}
}
});
} else {
this._chatRoomItemMap.forEach((value) => {
if (data != null) {
value.emit(events, data);
} else {
value.emit(events);
}
});
}
});
}
})
}
destory() {
this._chatRoomItemMap.forEach((value) => {
Expand All @@ -369,37 +372,33 @@ export class FcrChatRoomManager {
const { data } = await this._classRoomConnection.getChatRoomDetails({
chatRoomId: roomId,
});
const res = (data as unknown as AgoraIMChatRoomDetails[])[0];
const affiliations = res.affiliations;
const manager = this.createChat(roomId);
const list = await manager.getUserInfoList( affiliations
.filter((item) => !!item.member)
.map((item) => {
return item.member ? item.member : '';
}));
this._roomeUserMap.set(roomId,list);
const res = (data as unknown as AgoraIMChatRoomDetails[])[0];
const affiliations = res.affiliations;
const manager = this.createChat(roomId);
const list = await manager.getUserInfoList( affiliations
.filter((item) => !!item.member)
.map((item) => {
return item.member ? item.member : '';
}));
this._roomeUserMap.set(roomId,list);
}
/**
* 监听到用户进入房间
*/
private async listenerUserJoin(userId:string,chatRoomId:string){
const manager = this.createChat(this._defaultChatRoomeId);
const userInfoList = await manager.getUserInfoList([userId]);
this.changeRoomUserList(this._defaultChatRoomeId,userInfoList,true,false)
this.changeRoomUserList(chatRoomId,userInfoList,true,false)
if(chatRoomId !== this._defaultChatRoomeId){
this.changeRoomUserList(this._defaultChatRoomeId,userInfoList,true,false)
}
}
/**
* 监听到用户离开房间
*/
private async listenerUserLeft(userId:string,chatRoomId:string){
const manager = this.createChat(this._defaultChatRoomeId);
const userInfoList = await manager.getUserInfoList([userId]);
this.changeRoomUserList(this._defaultChatRoomeId,userInfoList,false,true)
this.changeRoomUserList(chatRoomId,userInfoList,false,true)
if(chatRoomId !== this._defaultChatRoomeId){
this.changeRoomUserList(this._defaultChatRoomeId,userInfoList,false,true)
}
}
/**
* 修改指定房间的用户列表
Expand All @@ -418,8 +417,24 @@ export class FcrChatRoomManager {
const idsToRemove = new Set(userList.map(item => item.userId));
list = list.filter(item => !idsToRemove.has(item.userId));
}
this._roomeUserMap.set(roomId,list)
this._roomeUserMap.set(roomId,this.removeDuplicatesByProperty(list))
}
/**
* 移除重复的用户
*/
private removeDuplicatesByProperty(arr:AgoraIMUserInfo[]) {
const seen = new Set();
return arr.filter(item => {
const key = item.userId;
if (seen.has(key)) {
return false; // 已经存在,跳过
} else {
seen.add(key);
return true; // 新的项,保留
}
});
}

/**
* 获取所有用户列表
*/
Expand Down
10 changes: 10 additions & 0 deletions src/components/svg-img/paths/application_screen_share.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';

import { PathOptions } from '../svg-dict';

export const path = (props: PathOptions) =>
<path fillRule="evenodd" clipRule="evenodd" d="M5.625 10.6256C5.625 8.55454 7.30393 6.87561 9.375 6.87561H20.625C22.6961 6.87561 24.375 8.55454 24.375 10.6256V15.6256C24.375 15.8429 24.3565 16.0559 24.321 16.2631C23.5979 15.8568 22.7635 15.625 21.875 15.625C19.545 15.625 17.5872 17.2188 17.0324 19.3756H9.375C7.30393 19.3756 5.625 17.6967 5.625 15.6256V10.6256ZM17.2386 22.5004C17.0042 21.9214 16.875 21.2884 16.875 20.6254H6.5625C6.04473 20.6254 5.625 21.0451 5.625 21.5629C5.625 22.0806 6.04473 22.5004 6.5625 22.5004H17.2386ZM18.1642 10.0559C17.8497 9.68901 17.2973 9.64652 16.9304 9.96102C16.5635 10.2755 16.521 10.8279 16.8355 11.1948L17.4724 11.9379H13.7499C11.5407 11.9379 9.74988 13.7287 9.74988 15.9379H11.4999C11.4999 14.6952 12.5072 13.6879 13.7499 13.6879H19.3749C19.7166 13.6879 20.027 13.4889 20.1698 13.1785C20.3126 12.868 20.2616 12.5029 20.0392 12.2434L18.1642 10.0559ZM25.625 20.625C25.625 22.6961 23.9461 24.375 21.875 24.375C19.8039 24.375 18.125 22.6961 18.125 20.625C18.125 18.5539 19.8039 16.875 21.875 16.875C23.9461 16.875 25.625 18.5539 25.625 20.625ZM24.1999 19.8088L21.7892 22.3088L21.3624 22.7515L20.9128 22.3319L19.5736 21.0819L20.4264 20.1681L21.3162 20.9985L23.3001 18.9412L24.1999 19.8088Z" fill="white"/>



export const viewBox = '0 0 30 30'
1 change: 1 addition & 0 deletions src/components/svg-img/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,5 @@ export enum SvgIconEnum {
MESSAGE_OPENED_NEW = 'message-opened-new',
MESSAGE_CLOSED_NEW = 'message-closed-new',
FCR_BTN_LOADING = 'fcr_btn_loading',
APPLICATION_SCREEN_SHARE = 'application_screen_share',
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
.fcr-chatroom-mobile-application-list-icon.bower{
background-color: #585D8C;
}
.fcr-chatroom-mobile-application-list-icon.screenShare{
background-color: #5768FF;
}
.fcr-chatroom-mobile-application-list-val{
flex: 1;
text-align: center;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,75 +1,119 @@
import classNames from 'classnames'
import React, { useEffect, useMemo, useState } from 'react'
import classNames from 'classnames';
import { useEffect } from 'react';
import { useStore } from '../../../../hooks/useStore';
import { SvgIconEnum, SvgImgMobile } from '../../../../../../../../components/svg-img';
import './index.css'
import './index.css';
import { observer } from 'mobx-react';
const ApplicationDialog = observer(({ setIsShowApplication }: {setIsShowApplication: (arg0: boolean) => void}) => {
import { transI18n } from 'agora-common-libs';
const ApplicationDialog = observer(
({ setIsShowApplication }: { setIsShowApplication: (arg0: boolean) => void }) => {
const {
roomStore: { isLandscape, forceLandscape, z0Widgets, setCurrentWidget, currentWidget },
roomStore: { isLandscape, forceLandscape, z0Widgets, setCurrentWidget, currentWidget },
} = useStore();
console.log('currentWidgetcurrentWidgetdialog', currentWidget)
const widgets = z0Widgets.filter((v: any) => v.widgetName !== 'easemobIM')
// if (!currentWidget) {
// setCurrentWidget(widgets[0])
// }
console.log('currentWidgetcurrentWidgetdialog', currentWidget);
const widgets = z0Widgets.filter((v: any) => v.widgetName !== 'easemobIM');

const handleClose = () => {
setIsShowApplication(false);
}
setIsShowApplication(false);
};
useEffect(() => {
document.body.addEventListener('click', handleClose, false);
}, [])
const handleSelectApplication = (e: { stopPropagation: () => void; }, widget: any) => {
e.stopPropagation()
setCurrentWidget(widget)
}
return (
<div className={classNames('fcr-chatroom-mobile-application', isLandscape && 'active')}>
<div className='fcr-chatroom-mobile-application-split'></div>
<div className='fcr-chatroom-mobile-application-lists'>
{
widgets.map((item: any) => {
return (
<div key={item.widgetId} className='fcr-chatroom-mobile-application-list' onClick={(e) => handleSelectApplication(e, item)}>
<div className='fcr-chatroom-mobile-application-list-left'>
<div className={classNames('fcr-chatroom-mobile-application-list-icon', item.widgetName === 'mediaPlayer' && 'video', item.widgetName === 'webView' && 'bower')}>
{item.widgetName === 'netlessBoard' && <SvgImgMobile
type={SvgIconEnum.APPLICATION_WHITEBOARD}
size={30}
landscape={isLandscape}
forceLandscape={forceLandscape}/>}
{item.widgetName === 'mediaPlayer' && <SvgImgMobile
type={SvgIconEnum.APPLICATION_VIDEO}
size={30}
landscape={isLandscape}
forceLandscape={forceLandscape}/>}
{item.widgetName === 'webView' && <SvgImgMobile
type={SvgIconEnum.APPLICATION_BOWER}
size={30}
landscape={isLandscape}
forceLandscape={forceLandscape}/>}
</div>
{(item.widgetName === 'netlessBoard' || item.widgetName === 'mediaPlayer') && <span className='fcr-chatroom-mobile-application-list-val'>{item.widgetName === 'netlessBoard' ? 'Whiteboard' : item.widgetName === 'mediaPlayer' ? item.webviewTitle : ''}</span>}
{
item.widgetName === 'webView' && <div className='fcr-chatroom-mobile-application-list-content'>
<span className='fcr-chatroom-mobile-application-list-title'>网页</span>
<span className='fcr-chatroom-mobile-application-list-des'>{item?.displayName || ''}</span>
</div>
}
</div>
<div className='fcr-chatroom-mobile-application-list-right'>
{currentWidget && currentWidget.widgetId === item.widgetId ? <SvgImgMobile
type={SvgIconEnum.CHAT_SELECT}
size={20}
landscape={isLandscape}
forceLandscape={forceLandscape}/> : <span className='fcr-chatroom-mobile-application-list-unselect'></span>}
</div>
</div>
)
})
}

{/* <div className='fcr-chatroom-mobile-application-list'>
document.body.addEventListener('click', handleClose, false);
}, []);
const handleSelectApplication = (e: { stopPropagation: () => void }, widget: any) => {
e.stopPropagation();
setCurrentWidget(widget);
};
return (
<div className={classNames('fcr-chatroom-mobile-application', isLandscape && 'active')}>
<div className="fcr-chatroom-mobile-application-split"></div>
<div className="fcr-chatroom-mobile-application-lists">
{widgets.map((item: any) => {
return (
<div
key={item.widgetId}
className="fcr-chatroom-mobile-application-list"
onClick={(e) => handleSelectApplication(e, item)}>
<div className="fcr-chatroom-mobile-application-list-left">
<div
className={classNames(
'fcr-chatroom-mobile-application-list-icon',
item.widgetName === 'mediaPlayer' && 'video',
item.widgetName === 'webView' && 'bower',
item.widgetName === 'screenShare' && 'screenShare',
)}>
{item.widgetName === 'netlessBoard' && (
<SvgImgMobile
type={SvgIconEnum.APPLICATION_WHITEBOARD}
size={30}
landscape={isLandscape}
forceLandscape={forceLandscape}
/>
)}
{item.widgetName === 'mediaPlayer' && (
<SvgImgMobile
type={SvgIconEnum.APPLICATION_VIDEO}
size={30}
landscape={isLandscape}
forceLandscape={forceLandscape}
/>
)}
{item.widgetName === 'webView' && (
<SvgImgMobile
type={SvgIconEnum.APPLICATION_BOWER}
size={30}
landscape={isLandscape}
forceLandscape={forceLandscape}
/>
)}
{item.widgetName === 'screenShare' && (
<SvgImgMobile
type={SvgIconEnum.APPLICATION_SCREEN_SHARE}
size={30}
landscape={isLandscape}
forceLandscape={forceLandscape}
/>
)}
</div>
{(item.widgetName === 'netlessBoard' || item.widgetName === 'mediaPlayer') && (
<span className="fcr-chatroom-mobile-application-list-val">
{item.widgetName === 'netlessBoard'
? 'Whiteboard'
: item.widgetName === 'mediaPlayer'
? item.webviewTitle
: ''}
</span>
)}
{item.widgetName === 'webView' && (
<div className="fcr-chatroom-mobile-application-list-content">
<span className="fcr-chatroom-mobile-application-list-title">网页</span>
<span className="fcr-chatroom-mobile-application-list-des">
{item?.displayName || ''}
</span>
</div>
)}
{item.widgetName === 'screenShare' && (
<span className="fcr-chatroom-mobile-application-list-val">
{transI18n('fcr_application_screen_share')}
</span>
)}
</div>
<div className="fcr-chatroom-mobile-application-list-right">
{currentWidget && currentWidget.widgetId === item.widgetId ? (
<SvgImgMobile
type={SvgIconEnum.CHAT_SELECT}
size={20}
landscape={isLandscape}
forceLandscape={forceLandscape}
/>
) : (
<span className="fcr-chatroom-mobile-application-list-unselect"></span>
)}
</div>
</div>
);
})}

{/* <div className='fcr-chatroom-mobile-application-list'>
<div className='fcr-chatroom-mobile-application-list-left'>
<div className='fcr-chatroom-mobile-application-list-icon video'>
<SvgImgMobile
Expand Down Expand Up @@ -107,7 +151,8 @@ const ApplicationDialog = observer(({ setIsShowApplication }: {setIsShowApplicat
</div>
</div> */}
</div>
</div>
)
})
export default ApplicationDialog
</div>
);
},
);
export default ApplicationDialog;
Loading

0 comments on commit 04b5453

Please sign in to comment.