Add null-guard for appEvent in PersistentApp (#8175)
This commit is contained in:
parent
e9b2aea97b
commit
4f57a4661d
1 changed files with 10 additions and 5 deletions
|
@ -41,15 +41,20 @@ export default class PersistentApp extends React.Component<IProps> {
|
||||||
this.room = context.getRoom(this.props.persistentRoomId);
|
this.room = context.getRoom(this.props.persistentRoomId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private get app(): IApp {
|
private get app(): IApp | null {
|
||||||
// get the widget data
|
// get the widget data
|
||||||
const appEvent = WidgetUtils.getRoomWidgets(this.room).find(ev =>
|
const appEvent = WidgetUtils.getRoomWidgets(this.room).find(ev =>
|
||||||
ev.getStateKey() === this.props.persistentWidgetId,
|
ev.getStateKey() === this.props.persistentWidgetId,
|
||||||
);
|
);
|
||||||
return WidgetUtils.makeAppConfig(
|
|
||||||
appEvent.getStateKey(), appEvent.getContent(), appEvent.getSender(),
|
if (appEvent) {
|
||||||
this.room.roomId, appEvent.getId(),
|
return WidgetUtils.makeAppConfig(
|
||||||
);
|
appEvent.getStateKey(), appEvent.getContent(), appEvent.getSender(),
|
||||||
|
this.room.roomId, appEvent.getId(),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(): JSX.Element {
|
public render(): JSX.Element {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue