mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-16 13:14:58 +08:00
Bind to the room instead of the client
Also add the other missing deregister handlers
This commit is contained in:
parent
a9c54153ee
commit
bf8a3d4419
@ -89,17 +89,18 @@ export default class RoomTile2 extends React.Component<IProps, IState> {
|
|||||||
notificationState: this.getNotificationState(),
|
notificationState: this.getNotificationState(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: We shouldn't have to listen to every room update
|
this.props.room.on("Room.receipt", this.handleRoomEventUpdate);
|
||||||
// We don't have a model which works in a better way though.
|
this.props.room.on("Room.timeline", this.handleRoomEventUpdate);
|
||||||
MatrixClientPeg.get().on("Room.receipt", this.tryUpdateIfRoomMatches);
|
this.props.room.on("Event.decrypted", this.handleRoomEventUpdate);
|
||||||
MatrixClientPeg.get().on("Room.timeline", this.tryUpdateIfRoomMatches);
|
this.props.room.on("Room.redaction", this.handleRoomEventUpdate);
|
||||||
MatrixClientPeg.get().on("Event.decrypted", this.tryUpdateIfRoomMatches);
|
|
||||||
MatrixClientPeg.get().on("Room.redaction", this.tryUpdateIfRoomMatches);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public componentWillUnmount() {
|
public componentWillUnmount() {
|
||||||
if (MatrixClientPeg.get()) {
|
if (this.props.room) {
|
||||||
MatrixClientPeg.get().removeListener("Room.receipt", this.tryUpdateIfRoomMatches);
|
this.props.room.removeListener("Room.receipt", this.handleRoomEventUpdate);
|
||||||
|
this.props.room.removeListener("Room.timeline", this.handleRoomEventUpdate);
|
||||||
|
this.props.room.removeListener("Event.decrypted", this.handleRoomEventUpdate);
|
||||||
|
this.props.room.removeListener("Room.redaction", this.handleRoomEventUpdate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,8 +111,10 @@ export default class RoomTile2 extends React.Component<IProps, IState> {
|
|||||||
return getEffectiveMembership(this.props.room.getMyMembership()) === EffectiveMembership.Invite;
|
return getEffectiveMembership(this.props.room.getMyMembership()) === EffectiveMembership.Invite;
|
||||||
}
|
}
|
||||||
|
|
||||||
private tryUpdateIfRoomMatches = (event: MatrixEvent) => {
|
private handleRoomEventUpdate = (event: MatrixEvent) => {
|
||||||
const roomId = event.getRoomId();
|
const roomId = event.getRoomId();
|
||||||
|
|
||||||
|
// Sanity check: should never happen
|
||||||
if (roomId !== this.props.room.roomId) return;
|
if (roomId !== this.props.room.roomId) return;
|
||||||
|
|
||||||
this.updateNotificationState();
|
this.updateNotificationState();
|
||||||
|
Loading…
Reference in New Issue
Block a user