Use optional chaining

Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
RMidhunSuresh 2021-08-06 17:23:01 +05:30
parent 2cae7c41d3
commit 187cf5cd28

View file

@ -270,7 +270,7 @@ export class Room extends BaseRoom {
_getPowerLevelsEvent(roomResponse) { _getPowerLevelsEvent(roomResponse) {
const isPowerlevelEvent = event => event.type === POWERLEVELS_EVENT_TYPE; const isPowerlevelEvent = event => event.type === POWERLEVELS_EVENT_TYPE;
const powerLevelEvent = roomResponse.timeline.events.find(isPowerlevelEvent) ?? roomResponse.state.events.find(isPowerlevelEvent); const powerLevelEvent = roomResponse.timeline?.events.find(isPowerlevelEvent) ?? roomResponse.state?.events.find(isPowerlevelEvent);
return powerLevelEvent; return powerLevelEvent;
} }