added event handling back
parent
6d98335368
commit
48633f76ab
|
@ -1047,7 +1047,7 @@ export const Commands = [
|
||||||
runFn: function(roomId, args) {
|
runFn: function(roomId, args) {
|
||||||
return success((async () => {
|
return success((async () => {
|
||||||
if (!args) {
|
if (!args) {
|
||||||
args = _t("sends confetti");
|
args = "sends confetti";
|
||||||
MatrixClientPeg.get().sendEmoteMessage(roomId, args);
|
MatrixClientPeg.get().sendEmoteMessage(roomId, args);
|
||||||
} else {
|
} else {
|
||||||
MatrixClientPeg.get().sendTextMessage(roomId, args);
|
MatrixClientPeg.get().sendTextMessage(roomId, args);
|
||||||
|
|
|
@ -73,6 +73,7 @@ import {XOR} from "../../@types/common";
|
||||||
import { IThreepidInvite } from "../../stores/ThreepidInviteStore";
|
import { IThreepidInvite } from "../../stores/ThreepidInviteStore";
|
||||||
import { CallState, CallType, MatrixCall } from "matrix-js-sdk/lib/webrtc/call";
|
import { CallState, CallType, MatrixCall } from "matrix-js-sdk/lib/webrtc/call";
|
||||||
import EffectsOverlay from "../views/elements/effects/EffectsOverlay";
|
import EffectsOverlay from "../views/elements/effects/EffectsOverlay";
|
||||||
|
import { isConfettiEmoji } from '../views/elements/effects/confetti';
|
||||||
|
|
||||||
const DEBUG = false;
|
const DEBUG = false;
|
||||||
let debuglog = function(msg: string) {};
|
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("deviceVerificationChanged", this.onDeviceVerificationChanged);
|
||||||
this.context.on("userTrustStatusChanged", this.onUserVerificationChanged);
|
this.context.on("userTrustStatusChanged", this.onUserVerificationChanged);
|
||||||
this.context.on("crossSigning.keysChanged", this.onCrossSigningKeysChanged);
|
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
|
// Start listening for RoomViewStore updates
|
||||||
this.roomStoreToken = RoomViewStore.addListener(this.onRoomViewStoreUpdate);
|
this.roomStoreToken = RoomViewStore.addListener(this.onRoomViewStoreUpdate);
|
||||||
this.rightPanelStoreToken = RightPanelStore.getSharedInstance().addListener(this.onRightPanelStoreUpdate);
|
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("deviceVerificationChanged", this.onDeviceVerificationChanged);
|
||||||
this.context.removeListener("userTrustStatusChanged", this.onUserVerificationChanged);
|
this.context.removeListener("userTrustStatusChanged", this.onUserVerificationChanged);
|
||||||
this.context.removeListener("crossSigning.keysChanged", this.onCrossSigningKeysChanged);
|
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);
|
window.removeEventListener('beforeunload', this.onPageUnload);
|
||||||
|
@ -795,6 +800,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) => {
|
private onRoomName = (room: Room) => {
|
||||||
if (this.state.room && room.roomId == this.state.room.roomId) {
|
if (this.state.room && room.roomId == this.state.room.roomId) {
|
||||||
|
|
Loading…
Reference in New Issue