added event handling back

pull/21833/head
Steffen Kolmer 2020-10-19 23:10:43 +02:00
parent 6d98335368
commit 48633f76ab
2 changed files with 26 additions and 1 deletions

View File

@ -1047,7 +1047,7 @@ export const Commands = [
runFn: function(roomId, args) {
return success((async () => {
if (!args) {
args = _t("sends confetti");
args = "sends confetti";
MatrixClientPeg.get().sendEmoteMessage(roomId, args);
} else {
MatrixClientPeg.get().sendTextMessage(roomId, args);

View File

@ -73,6 +73,7 @@ import {XOR} from "../../@types/common";
import { IThreepidInvite } from "../../stores/ThreepidInviteStore";
import { CallState, CallType, MatrixCall } from "matrix-js-sdk/lib/webrtc/call";
import EffectsOverlay from "../views/elements/effects/EffectsOverlay";
import { isConfettiEmoji } from '../views/elements/effects/confetti';
const DEBUG = false;
let debuglog = function(msg: string) {};
@ -247,6 +248,8 @@ export default class RoomView extends React.Component<IProps, IState> {
this.context.on("deviceVerificationChanged", this.onDeviceVerificationChanged);
this.context.on("userTrustStatusChanged", this.onUserVerificationChanged);
this.context.on("crossSigning.keysChanged", this.onCrossSigningKeysChanged);
this.context.on("Event.decrypted", this.onEventDecrypted);
this.context.on("event", this.onEvent);
// Start listening for RoomViewStore updates
this.roomStoreToken = RoomViewStore.addListener(this.onRoomViewStoreUpdate);
this.rightPanelStoreToken = RightPanelStore.getSharedInstance().addListener(this.onRightPanelStoreUpdate);
@ -567,6 +570,8 @@ export default class RoomView extends React.Component<IProps, IState> {
this.context.removeListener("deviceVerificationChanged", this.onDeviceVerificationChanged);
this.context.removeListener("userTrustStatusChanged", this.onUserVerificationChanged);
this.context.removeListener("crossSigning.keysChanged", this.onCrossSigningKeysChanged);
this.context.removeListener("Event.decrypted", this.onEventDecrypted);
this.context.removeListener("event", this.onEvent);
}
window.removeEventListener('beforeunload', this.onPageUnload);
@ -796,6 +801,26 @@ export default class RoomView extends React.Component<IProps, IState> {
}
};
private onEventDecrypted = (ev) => {
if (ev.isBeingDecrypted() || ev.isDecryptionFailure() ||
this.state.room.getUnreadNotificationCount() === 0) return;
this.handleConfetti(ev);
};
private onEvent = (ev) => {
if (ev.isBeingDecrypted() || ev.isDecryptionFailure()) return;
this.handleConfetti(ev);
};
private handleConfetti = (ev) => {
if (this.state.matrixClientIsReady) {
const messageBody = 'sends confetti';
if (isConfettiEmoji(ev.getContent()) || ev.getContent().body === messageBody) {
dis.dispatch({action: 'effects.confetti'});
}
}
};
private onRoomName = (room: Room) => {
if (this.state.room && room.roomId == this.state.room.roomId) {
this.forceUpdate();