Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit d7c1a6f

Browse files
author
Germain
authored
[Release] Add null-guard for appEvent in PersistentApp (#8176)
1 parent 00d3248 commit d7c1a6f

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/components/views/elements/PersistentApp.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,20 @@ export default class PersistentApp extends React.Component<IProps> {
4141
this.room = context.getRoom(this.props.persistentRoomId);
4242
}
4343

44-
private get app(): IApp {
44+
private get app(): IApp | null {
4545
// get the widget data
4646
const appEvent = WidgetUtils.getRoomWidgets(this.room).find(ev =>
4747
ev.getStateKey() === this.props.persistentWidgetId,
4848
);
49-
return WidgetUtils.makeAppConfig(
50-
appEvent.getStateKey(), appEvent.getContent(), appEvent.getSender(),
51-
this.room.roomId, appEvent.getId(),
52-
);
49+
50+
if (appEvent) {
51+
return WidgetUtils.makeAppConfig(
52+
appEvent.getStateKey(), appEvent.getContent(), appEvent.getSender(),
53+
this.room.roomId, appEvent.getId(),
54+
);
55+
} else {
56+
return null;
57+
}
5358
}
5459

5560
public render(): JSX.Element {

0 commit comments

Comments
 (0)