You've already forked matrix-react-sdk
							
							
				mirror of
				https://github.com/matrix-org/matrix-react-sdk.git
				synced 2025-11-04 11:51:45 +03:00 
			
		
		
		
	added event handling back
This commit is contained in:
		@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
@@ -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) => {
 | 
			
		||||
        if (this.state.room && room.roomId == this.state.room.roomId) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user