diff --git a/src/common/im/wrapper/agora-chat-room-manager.ts b/src/common/im/wrapper/agora-chat-room-manager.ts index 05ab85c8..144d3bf4 100644 --- a/src/common/im/wrapper/agora-chat-room-manager.ts +++ b/src/common/im/wrapper/agora-chat-room-manager.ts @@ -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; logs: [string, unknown]; @@ -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; @@ -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) => { @@ -369,15 +372,15 @@ 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); } /** * 监听到用户进入房间 @@ -385,10 +388,8 @@ export class FcrChatRoomManager { 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) - } } /** * 监听到用户离开房间 @@ -396,10 +397,8 @@ export class FcrChatRoomManager { 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) - } } /** * 修改指定房间的用户列表 @@ -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; // 新的项,保留 + } + }); } + /** * 获取所有用户列表 */ diff --git a/src/components/svg-img/paths/application_screen_share.tsx b/src/components/svg-img/paths/application_screen_share.tsx new file mode 100644 index 00000000..df8a8d9f --- /dev/null +++ b/src/components/svg-img/paths/application_screen_share.tsx @@ -0,0 +1,10 @@ +import React from 'react'; + +import { PathOptions } from '../svg-dict'; + +export const path = (props: PathOptions) => + + + + +export const viewBox = '0 0 30 30' \ No newline at end of file diff --git a/src/components/svg-img/type.ts b/src/components/svg-img/type.ts index 3e31bd82..28b04b81 100644 --- a/src/components/svg-img/type.ts +++ b/src/components/svg-img/type.ts @@ -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', } diff --git a/src/gallery/classroom/hx-chat/fcr-chatroom/container/mobile/components/application-dialog/index.css b/src/gallery/classroom/hx-chat/fcr-chatroom/container/mobile/components/application-dialog/index.css index 98a583ab..a2151b24 100644 --- a/src/gallery/classroom/hx-chat/fcr-chatroom/container/mobile/components/application-dialog/index.css +++ b/src/gallery/classroom/hx-chat/fcr-chatroom/container/mobile/components/application-dialog/index.css @@ -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; diff --git a/src/gallery/classroom/hx-chat/fcr-chatroom/container/mobile/components/application-dialog/index.tsx b/src/gallery/classroom/hx-chat/fcr-chatroom/container/mobile/components/application-dialog/index.tsx index aef05996..f01399bc 100644 --- a/src/gallery/classroom/hx-chat/fcr-chatroom/container/mobile/components/application-dialog/index.tsx +++ b/src/gallery/classroom/hx-chat/fcr-chatroom/container/mobile/components/application-dialog/index.tsx @@ -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 ( -
-
-
- { - widgets.map((item: any) => { - return ( -
handleSelectApplication(e, item)}> -
-
- {item.widgetName === 'netlessBoard' && } - {item.widgetName === 'mediaPlayer' && } - {item.widgetName === 'webView' && } -
- {(item.widgetName === 'netlessBoard' || item.widgetName === 'mediaPlayer') && {item.widgetName === 'netlessBoard' ? 'Whiteboard' : item.widgetName === 'mediaPlayer' ? item.webviewTitle : ''}} - { - item.widgetName === 'webView' &&
- 网页 - {item?.displayName || ''} -
- } -
-
- {currentWidget && currentWidget.widgetId === item.widgetId ? : } -
-
- ) - }) - } - - {/*
+ document.body.addEventListener('click', handleClose, false); + }, []); + const handleSelectApplication = (e: { stopPropagation: () => void }, widget: any) => { + e.stopPropagation(); + setCurrentWidget(widget); + }; + return ( +
+
+
+ {widgets.map((item: any) => { + return ( +
handleSelectApplication(e, item)}> +
+
+ {item.widgetName === 'netlessBoard' && ( + + )} + {item.widgetName === 'mediaPlayer' && ( + + )} + {item.widgetName === 'webView' && ( + + )} + {item.widgetName === 'screenShare' && ( + + )} +
+ {(item.widgetName === 'netlessBoard' || item.widgetName === 'mediaPlayer') && ( + + {item.widgetName === 'netlessBoard' + ? 'Whiteboard' + : item.widgetName === 'mediaPlayer' + ? item.webviewTitle + : ''} + + )} + {item.widgetName === 'webView' && ( +
+ 网页 + + {item?.displayName || ''} + +
+ )} + {item.widgetName === 'screenShare' && ( + + {transI18n('fcr_application_screen_share')} + + )} +
+
+ {currentWidget && currentWidget.widgetId === item.widgetId ? ( + + ) : ( + + )} +
+
+ ); + })} + + {/*
*/}
-
- ) -}) -export default ApplicationDialog \ No newline at end of file +
+ ); + }, +); +export default ApplicationDialog; diff --git a/src/gallery/classroom/hx-chat/fcr-chatroom/container/mobile/components/input/index.tsx b/src/gallery/classroom/hx-chat/fcr-chatroom/container/mobile/components/input/index.tsx index c01c8b40..f2177a21 100644 --- a/src/gallery/classroom/hx-chat/fcr-chatroom/container/mobile/components/input/index.tsx +++ b/src/gallery/classroom/hx-chat/fcr-chatroom/container/mobile/components/input/index.tsx @@ -19,8 +19,10 @@ export const FcrChatRoomH5Inputs = observer( showEmoji, onShowEmojiChanged, emojiContainer, + screenShareStream, }: { showEmoji: boolean; + screenShareStream: any; onShowEmojiChanged: (show: boolean) => void; emojiContainer: HTMLDivElement | null; }) => { @@ -195,9 +197,12 @@ export const FcrChatRoomH5Inputs = observer( }, []); const handleShowApplicatioon = (e: { stopPropagation: () => void }) => { e.stopPropagation(); - if (widgets.length === 0) { - addToast(transI18n('fcr_teacher_no_use_textbooks'), 'warning'); - return; + const haveShare = isLandscape && screenShareStream; + if(!haveShare){ + if (widgets.length === 0) { + addToast(transI18n('fcr_teacher_no_use_textbooks'), 'warning'); + return; + } } setIsShowApplication(!isShowApplication); }; @@ -406,7 +411,7 @@ export const FcrChatRoomH5Inputs = observer(
@@ -416,7 +421,7 @@ export const FcrChatRoomH5Inputs = observer( type={SvgIconEnum.APPLICATION} size={30}> - {widgets.length > 99 ? '...' : widgets.length} + {widgets.length > 99 ? '...' : widgets.length}
@@ -652,7 +657,7 @@ export const FcrChatRoomH5Inputs = observer(
@@ -662,7 +667,7 @@ export const FcrChatRoomH5Inputs = observer( type={SvgIconEnum.APPLICATION} size={30}> - {widgets.length > 99 ? '...' : widgets.length} + {widgets.length > 99 ? '...' : widgets.length}
diff --git a/src/gallery/classroom/hx-chat/fcr-chatroom/container/mobile/index.tsx b/src/gallery/classroom/hx-chat/fcr-chatroom/container/mobile/index.tsx index 9eb80148..79d42244 100644 --- a/src/gallery/classroom/hx-chat/fcr-chatroom/container/mobile/index.tsx +++ b/src/gallery/classroom/hx-chat/fcr-chatroom/container/mobile/index.tsx @@ -16,7 +16,7 @@ export const FcrChatRoomH5 = observer(() => { const [showEmoji, setShowEmoji] = useState(false); const { - roomStore: { orientation, forceLandscape }, + roomStore: { orientation, forceLandscape,screenShareStream }, } = useStore(); const isLandscape = orientation === OrientationEnum.landscape || forceLandscape; return ( @@ -53,6 +53,7 @@ export const FcrChatRoomH5 = observer(() => {
, @@ -71,6 +72,7 @@ export const FcrChatRoomH5 = observer(() => {
)} diff --git a/src/gallery/classroom/hx-chat/fcr-chatroom/store/index.ts b/src/gallery/classroom/hx-chat/fcr-chatroom/store/index.ts index 7a015f0b..de9cb729 100644 --- a/src/gallery/classroom/hx-chat/fcr-chatroom/store/index.ts +++ b/src/gallery/classroom/hx-chat/fcr-chatroom/store/index.ts @@ -42,7 +42,7 @@ export class FcrChatRoomStore { this._addListeners(); this._init(); this.roomId = roomId; - console.log('roomIdroomIdroomId', roomId) + console.log('roomIdroomIdroomId', roomId); } private _addListeners() { this.fcrChatRoom.on( @@ -72,22 +72,12 @@ export class FcrChatRoomStore { Logger.error('[FcrChatRoom] connection disConnected'); } if (connectionState === AgoraIMConnectionState.Connected) { - const users = AgoraIM.getRoomManager(this.fcrChatRoom.getRoomId())?.getAllUserList() - if(users){ - this.userStore.updateAllUsers(users) + const users = AgoraIM.getRoomManager(this.fcrChatRoom.getRoomId())?.getAllUserList(); + if (users) { + this.userStore.updateAllUsers(users); } - // this.roomStore.getChatRoomDetails().then((details) => { - // const { affiliations } = details; - // this.userStore.updateUsers( - // affiliations - // .filter((item) => !!item.member) - // .map((item) => { - // return item.member!; - // }), - // ); - // }); + if (this.roomStore.isHost) this.userStore.getMutedUserList(); - this.roomStore.getWidgets() this.messageStore.getHistoryMessageList(); this.messageStore.getAnnouncement(); } @@ -130,10 +120,12 @@ export class FcrChatRoomStore { //@ts-ignore return this._widget.shareUIStore.addSingletonToast(transI18n('chat.join_room_fail'), 'error'); } - if (AgoraIM.getConnectState(this.fcrChatRoom.getRoomId()) === AgoraIMConnectionState.Connected) { - const users = AgoraIM.getRoomManager(this.fcrChatRoom.getRoomId())?.getAllUserList() - if(users){ - this.userStore.updateAllUsers(users) + if ( + AgoraIM.getConnectState(this.fcrChatRoom.getRoomId()) === AgoraIMConnectionState.Connected + ) { + const users = AgoraIM.getRoomManager(this.fcrChatRoom.getRoomId())?.getAllUserList(); + if (users) { + this.userStore.updateAllUsers(users); } // this.roomStore.getChatRoomDetails().then((details) => { // const { affiliations } = details; @@ -146,7 +138,7 @@ export class FcrChatRoomStore { // ); // }); if (this.roomStore.isHost) this.userStore.getMutedUserList(); - this.roomStore.getWidgets() + this.roomStore.getWidgets(); this.messageStore.getHistoryMessageList(); this.messageStore.getAnnouncement(); } diff --git a/src/gallery/classroom/hx-chat/fcr-chatroom/store/room.ts b/src/gallery/classroom/hx-chat/fcr-chatroom/store/room.ts index 466dd534..4fb1180b 100644 --- a/src/gallery/classroom/hx-chat/fcr-chatroom/store/room.ts +++ b/src/gallery/classroom/hx-chat/fcr-chatroom/store/room.ts @@ -1,11 +1,12 @@ import { AgoraHXChatWidget } from '../..'; -import { computed, observable, action, runInAction } from 'mobx'; +import { computed, observable, action, runInAction, reaction } from 'mobx'; import { AgoraIMBase, AgoraIMEvents } from '../../../../../common/im/wrapper/typs'; import dayjs from 'dayjs'; import { ThumbsUpAni } from '../container/mobile/components/thumbs-up/thumbs-up'; import { transI18n, bound, Scheduler, AgoraWidgetBase } from 'agora-common-libs'; import { AgoraExtensionRoomEvent, AgoraExtensionWidgetEvent } from '../../../../../events'; import { OrientationEnum } from '../../type'; +import { EduStream } from 'agora-edu-core'; export enum MobileCallState { Initialize = 'initialize', Processing = 'processing', @@ -15,6 +16,7 @@ export enum MobileCallState { DeviceOffCall = 'deviceOffCall', } export class RoomStore { + private _disposers: (() => void)[] = []; roomName = this._widget.classroomConfig.sessionInfo.roomName; @observable mobileCallState: MobileCallState = MobileCallState.Initialize; @observable messageVisible = false; @@ -48,6 +50,21 @@ export class RoomStore { constructor(private _widget: AgoraHXChatWidget, private _fcrChatRoom: AgoraIMBase) { this._addEventListeners(); this._initializeThumbsCount(); + this._disposers.push( + reaction( + () => this.screenShareStream, + () => { + this.resetDefaultCurrentWidget(); + const shareWidget = this._widgetInstanceList.find( + (item) => item.widgetName === 'screenShare', + ); + if (shareWidget) { + this.setCurrentWidget(shareWidget); + } + }, + ), + ); + this.getWidgets(); } isHost = this._widget.classroomConfig.sessionInfo.role === 1 || @@ -99,47 +116,84 @@ export class RoomStore { get isBreakOutRoomIn() { return this._widget.classroomStore.groupStore.currentSubRoom !== undefined; } + + /** + * 屏幕共享流 + * @returns + */ + @computed + get screenShareStream(): EduStream | undefined { + const streamUuid = this._widget.classroomStore.roomStore.screenShareStreamUuid as string; + const stream = this._widget.classroomStore.streamStore.streamByStreamUuid.get(streamUuid); + return stream; + } + getWidgets() { - console.log('getWidgetsgetWidgetsgetWidgets') - this._widget.broadcast(AgoraExtensionRoomEvent.ChangeRoom, true) - this._widget.addBroadcastListener({ - messageType: AgoraExtensionRoomEvent.GetApplications, - onMessage: this._handleGetWidgets, - }); - this._widget.addBroadcastListener({ - messageType: AgoraExtensionRoomEvent.DefaultCurrentApplication, - onMessage: this._handleGetDefaultWidget, - }); + console.log('getWidgetsgetWidgetsgetWidgets'); + this._widget.broadcast(AgoraExtensionRoomEvent.ChangeRoom, true); } @bound private _handleGetWidgets(widgetInstances: Record) { console.log( 'AgoraExtensionRoomEvent.GetApplications_handleGetWidgets', - this._widget.classroomStore.widgetStore.widgetController + this._widget.classroomStore.widgetStore.widgetController, ); this._widgetInstanceList = Object.values(widgetInstances); - const widgets = this._widgetInstanceList.filter(({ zContainer }) => zContainer === 0); - const arr: any = [] - for (let i = 0; i < widgets.length; i++) { - const item = widgets[i]; - arr.unshift(item) - } - const allWidgets = arr.filter((v) => v.widgetName !== 'easemobIM'); - if (!this.currentWidget) { - this.setCurrentWidget(allWidgets[0]); - } + this.resetDefaultCurrentWidget(); } @computed get z0Widgets() { console.log('AgoraExtensionRoomEvent.GetApplications_z0Widgets', this._widgetInstanceList); const widgets = this._widgetInstanceList.filter(({ zContainer }) => zContainer === 0); - const arr: any = [] + const arr: any = []; for (let i = 0; i < widgets.length; i++) { + const item = widgets[i]; + arr.unshift(item); + } + return arr; + } + + /** + * 重置默认当前的weidget,如果未设置 + */ + @action.bound + private resetDefaultCurrentWidget() { + if (this.screenShareStream && this.isLandscape) { + const hasScreenShare = this._widgetInstanceList.some( + (item) => item.widgetName === 'screenShare', + ); + if (!hasScreenShare) { + this._widgetInstanceList.push( + new ScreenShareWidget(this._widget.widgetController, this._widget.classroomStore), + ); + } + this.setCurrentWidget( + this._widgetInstanceList.find((item) => item.widgetName === 'screenShare'), + ); + } + if (!this.isLandscape || !this.screenShareStream) { + this._widgetInstanceList = this._widgetInstanceList.filter( + (item) => item.widgetName !== 'screenShare', + ); + if (this.currentWidget?.widgetName === 'screenShare') { + this.setCurrentWidget(undefined); + } + } + + if (!this.currentWidget || 'easemobIM' === this.currentWidget?.widgetId) { + const widgets = this._widgetInstanceList.filter(({ zContainer }) => zContainer === 0); + console.log('AgoraExtensionRoomEvent.GetApplications_z0Widgets', this._widgetInstanceList); + + const arr: any = []; + for (let i = 0; i < widgets.length; i++) { const item = widgets[i]; - arr.unshift(item) + arr.unshift(item); + } + const allWidgets = arr.filter((v: { widgetName: string }) => v.widgetName !== 'easemobIM'); + this.setCurrentWidget(allWidgets[0]); } - return arr } + @action.bound setCurrentWidget(widget: any) { this.currentWidget = widget; @@ -148,7 +202,7 @@ export class RoomStore { @action.bound _handleGetDefaultWidget(widget: any) { if (widget) { - console.log('_handleGetDefaultWidget_handleGetDefaultWidget', widget) + console.log('_handleGetDefaultWidget_handleGetDefaultWidget', widget); this.setCurrentWidget(widget); this.currentWidget = widget; } @@ -160,6 +214,7 @@ export class RoomStore { messageType: AgoraExtensionWidgetEvent.PollMinimizeStateChanged, onMessage: this._handlePollMinimizeStateChanged, }); + this._widget.addBroadcastListener({ messageType: AgoraExtensionRoomEvent.GetApplications, onMessage: this._handleGetWidgets, @@ -332,7 +387,7 @@ export class RoomStore { async getChatRoomDetails() { const { mute, affiliations } = await this._fcrChatRoom.getChatRoomDetails(); - + runInAction(() => { this.allMuted = mute; }); @@ -348,6 +403,8 @@ export class RoomStore { }) { this.orientation = params.orientation; this.forceLandscape = params.forceLandscape; + + this.resetDefaultCurrentWidget(); } @bound quitForceLandscape() { @@ -427,5 +484,15 @@ export class RoomStore { destroy() { this._removeEventListeners(); + this._disposers.forEach((fn) => fn()); + } +} + +class ScreenShareWidget extends AgoraWidgetBase { + get widgetName(): string { + return 'screenShare'; + } + get widgetId(): string { + return 'screenShare'; } } diff --git a/src/gallery/classroom/hx-chat/fcr-chatroom/store/user.ts b/src/gallery/classroom/hx-chat/fcr-chatroom/store/user.ts index f0add066..8a974774 100644 --- a/src/gallery/classroom/hx-chat/fcr-chatroom/store/user.ts +++ b/src/gallery/classroom/hx-chat/fcr-chatroom/store/user.ts @@ -198,6 +198,7 @@ export class UserStore { @bound async updateAllUsers(users: AgoraIMUserInfo[]) { runInAction(() => { + this.userMap.clear() users.forEach((user) => { if (user.ext.role === 1 || user.ext.role === 2) { this.userMap.set(user.userId, user); @@ -207,19 +208,23 @@ export class UserStore { } @bound private async _onUserJoined(user: string) { - this.updateUsers([user]); - if (this.joinedUser) return; - const userInfoList = await this._fcrChatRoom.getUserInfoList([user]); - const joinedUser = userInfoList[0]; - if (joinedUser.ext.role !== 2) return; - runInAction(() => { - if (joinedUser) this.joinedUser = joinedUser; - }); - Scheduler.shared.addDelayTask(() => { - runInAction(() => { - this.joinedUser = undefined; - }); - }, this.userCarouselAnimDelay + 500); + const users = AgoraIM.getRoomManager(this._fcrChatRoom.getRoomId())?.getAllUserList(); + if (users) { + this.updateAllUsers(users); + } + // this.updateUsers([user]); + // if (this.joinedUser) return; + // const userInfoList = await this._fcrChatRoom.getUserInfoList([user]); + // const joinedUser = userInfoList[0]; + // if (joinedUser.ext.role !== 2) return; + // runInAction(() => { + // if (joinedUser) this.joinedUser = joinedUser; + // }); + // Scheduler.shared.addDelayTask(() => { + // runInAction(() => { + // this.joinedUser = undefined; + // }); + // }, this.userCarouselAnimDelay + 500); } @computed get teacherName() { return this._widget.classroomStore.roomStore.flexProps['teacherName']; diff --git a/src/gallery/classroom/hx-chat/locales/en_US.js b/src/gallery/classroom/hx-chat/locales/en_US.js index 12a93b39..e99a8337 100644 --- a/src/gallery/classroom/hx-chat/locales/en_US.js +++ b/src/gallery/classroom/hx-chat/locales/en_US.js @@ -74,8 +74,8 @@ const enUS = { fcr_chat_dialog_placeholder: 'Enter a name', fcr_H5_tips_arrive: 'joined', fcr_H5_tips_join: 'Failed to join the room', - fcr_H5_tips_chat_hidden: 'The chat room has been closed', - fcr_H5_tips_chat_display: 'The chat room has been opened', + fcr_H5_tips_chat_hidden: 'The chat room has been hidden', + fcr_H5_tips_chat_display: 'The chat room has been visible', fcr_H5_mute_user_msg: 'You have been muted by teacher', fcr_H5_unmute_user_msg: 'You have been unmuted by teacher', fcr_H5_button_chat: 'Chat', @@ -83,6 +83,7 @@ const enUS = { fcr_teacher_use_collected_tip: 'The teaching materials used in the course will be collected here', fcr_participants_tips_lower_hand: 'Lower Hand', fcr_chat_options_no_one_room: 'The student and you are not in the same room, so it is impossible to operate.', + fcr_application_screen_share: 'Screen Share', }; export default enUS; diff --git a/src/gallery/classroom/hx-chat/locales/zh_CN.js b/src/gallery/classroom/hx-chat/locales/zh_CN.js index 20453895..7e17eab8 100644 --- a/src/gallery/classroom/hx-chat/locales/zh_CN.js +++ b/src/gallery/classroom/hx-chat/locales/zh_CN.js @@ -85,5 +85,6 @@ const im_CN = { fcr_teacher_use_collected_tip: '课程中使用的教材会收纳到此处', fcr_participants_tips_lower_hand: '手放下', fcr_chat_options_no_one_room: '该学生和您不在一个房间,无法操作', + fcr_application_screen_share: '屏幕共享', }; export default im_CN; diff --git a/src/gallery/classroom/stream-media/index.tsx b/src/gallery/classroom/stream-media/index.tsx index 415c6fc1..317354ec 100644 --- a/src/gallery/classroom/stream-media/index.tsx +++ b/src/gallery/classroom/stream-media/index.tsx @@ -30,7 +30,8 @@ export class FcrStreamMediaPlayerWidget extends FcrUISceneWidget { @computed get hasPrivilege() { const { role } = this.classroomConfig.sessionInfo; - return [1, 3].includes(role) || this._privilege; + return [1, 3].includes(role); + // return [1, 3].includes(role) || this._privilege; } get displayName() { return this.webviewTitle; diff --git a/src/gallery/classroom/whiteboard/app.tsx b/src/gallery/classroom/whiteboard/app.tsx index 64840e5b..5fc8fedd 100644 --- a/src/gallery/classroom/whiteboard/app.tsx +++ b/src/gallery/classroom/whiteboard/app.tsx @@ -29,11 +29,11 @@ export const App = ({ widget }: { widget: FcrBoardWidget }) => { }, 100); const targetElement = document.querySelector('.streams-swiper-vert'); - let resizeObserver: any = null; + let resizeObserver: ResizeObserver | null = null; if (targetElement) { resizeObserver = new ResizeObserver((entries) => { - for (let entry of entries) { + for (const entry of entries) { const slideWidth = entry.contentRect.width; _setToolbarDockPosition(slideWidth); } @@ -51,7 +51,7 @@ export const App = ({ widget }: { widget: FcrBoardWidget }) => { onMessage: _resetToolPosition, }); return () => { - resizeObserver.unobserve(targetElement); + targetElement && resizeObserver?.unobserve(targetElement); widget.widgetController.removeBroadcastListener({ messageType: AgoraExtensionRoomEvent.MobileLandscapeToolBarVisibleChanged, diff --git a/src/gallery/scene/chatroom/fcr-chatroom/store/user.ts b/src/gallery/scene/chatroom/fcr-chatroom/store/user.ts index 8ad98003..666a0998 100644 --- a/src/gallery/scene/chatroom/fcr-chatroom/store/user.ts +++ b/src/gallery/scene/chatroom/fcr-chatroom/store/user.ts @@ -92,6 +92,7 @@ export class UserStore { @bound async updateAllUsers(users: AgoraIMUserInfo[]) { runInAction(() => { + this.userMap.clear() users.forEach((user) => { if (user.ext.role === 1 || user.ext.role === 2) { this.userMap.set(user.userId, user); @@ -179,7 +180,11 @@ export class UserStore { } @bound private async _onUserJoined(userUuid: string) { - this.updateUsers([userUuid]); + const users = AgoraIM.getRoomManager(this._fcrChatRoom.getRoomId())?.getAllUserList(); + if (users) { + this.updateAllUsers(users); + } + // this.updateUsers([userUuid]); } @action.bound private async _onUserLeft(userUuid: string) { diff --git a/src/gallery/scene/stream-media/index.tsx b/src/gallery/scene/stream-media/index.tsx index b197e32a..5cb6b27c 100644 --- a/src/gallery/scene/stream-media/index.tsx +++ b/src/gallery/scene/stream-media/index.tsx @@ -28,7 +28,8 @@ export class FcrStreamMediaPlayerWidget extends FcrUISceneWidget { @computed get hasPrivilege() { const { role } = this.classroomConfig.sessionInfo; - return [1, 3].includes(role) || this._privilege; + return [1, 3].includes(role); + // return [1, 3].includes(role) || this._privilege; } get displayName() { return this.webviewTitle; diff --git a/src/gallery/scene/webview/index.tsx b/src/gallery/scene/webview/index.tsx index 6192508d..4f05453b 100644 --- a/src/gallery/scene/webview/index.tsx +++ b/src/gallery/scene/webview/index.tsx @@ -17,7 +17,7 @@ export class FcrWebviewWidget extends FcrUISceneWidget { } get hasPrivilege() { const { role } = this.classroomConfig.sessionInfo; - return [1, 3].includes(role) || this._privilege; + return [1, 3].includes(role); } get displayName(): string { return this.webviewTitle;