mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-14 01:35:54 +03:00
null checks added
This commit is contained in:
parent
674060ed93
commit
19395f3c3c
2 changed files with 9 additions and 9 deletions
|
@ -831,14 +831,14 @@ export default class RoomView extends React.Component<IProps, IState> {
|
|||
};
|
||||
|
||||
private handleEffects = (ev) => {
|
||||
if (this.state.room.getUnreadNotificationCount() === 0) return;
|
||||
if (this.state.matrixClientIsReady) {
|
||||
effects.forEach(effect => {
|
||||
if (containsEmoji(ev.getContent(), effect.emojis) || ev.getContent().msgtype === effect.msgType) {
|
||||
dis.dispatch({action: `effects.${effect.command}`});
|
||||
}
|
||||
})
|
||||
}
|
||||
if (!this.state.room ||
|
||||
!this.state.matrixClientIsReady ||
|
||||
this.state.room.getUnreadNotificationCount() === 0) return;
|
||||
effects.forEach(effect => {
|
||||
if (containsEmoji(ev.getContent(), effect.emojis) || ev.getContent().msgtype === effect.msgType) {
|
||||
dis.dispatch({action: `effects.${effect.command}`});
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
private onRoomName = (room: Room) => {
|
||||
|
|
|
@ -4,5 +4,5 @@
|
|||
* @param {Array<string>} emojis The list of emojis to check for
|
||||
*/
|
||||
export const containsEmoji = (content: { msgtype: string, body: string }, emojis: Array<string>): boolean => {
|
||||
return emojis.some((emoji) => content.body.includes(emoji));
|
||||
return emojis.some((emoji) => content.body && content.body.includes(emoji));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue