Skip to content

Commit

Permalink
fix: widget error
Browse files Browse the repository at this point in the history
zhanheng committed Aug 8, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent c99e16b commit 94f8232
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/uistores/widget/index.ts
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ export class WidgetUIStore extends EduUIStoreBase {
private _registeredWidgets: Record<string, typeof AgoraWidgetBase> = {};
private _viewportResizeObserver?: ResizeObserver;
@observable
private _currentWidget: any;
private _currentWidget?: AgoraWidgetBase;
@observable
private _widgetInstances: Record<string, AgoraWidgetBase> = {};
private _stateListener = {
@@ -68,15 +68,15 @@ export class WidgetUIStore extends EduUIStoreBase {
return this.widgetInstanceList.filter(({ zContainer }) => zContainer === 10);
}
@action.bound
setCurrentWidget(widget: any) {
setCurrentWidget(widget: AgoraWidgetBase) {
const { widgetController } = this.classroomStore.widgetStore;
if (widgetController) {
console.log('setCurrentWidgetsetCurrentWidget', widget);
widgetController.broadcast(AgoraExtensionRoomEvent.DefaultCurrentApplication, widget);
}
}
@action.bound
private _setCurrentWidget(widget: any) {
private _setCurrentWidget(widget: AgoraWidgetBase) {
this._currentWidget = widget;
}
@action.bound
@@ -198,7 +198,7 @@ export class WidgetUIStore extends EduUIStoreBase {
console.log('_handleWidgetInactive_handleWidgetInactive', this.z0Widgets, widgetId);
const arr = this.z0Widgets.filter((v: { widgetId: string }) => v.widgetId !== widgetId);
const index = arr.findIndex(
(v: { widgetId: string }) => v.widgetId === this._currentWidget.widgetId,
(v: { widgetId: string }) => v.widgetId === this._currentWidget?.widgetId,
);
if (index === -1) {
this.setCurrentWidget(arr[0]);
@@ -330,7 +330,7 @@ export class WidgetUIStore extends EduUIStoreBase {

@bound
private _handleBecomeInactive(widgetId: string) {
if (this._currentWidget.widgetId === widgetId) {
if (this._currentWidget?.widgetId === widgetId) {
this._setCurrentWidget(this.z0Widgets[0]);
}
this.destroyWidget(widgetId);

0 comments on commit 94f8232

Please sign in to comment.