mirror of https://github.com/vector-im/riot-web
React to MatrixEvent sender/target sentinels being updated for rendering state events
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>t3chguy/sentinels
parent
ebef0d353e
commit
bde3142b28
|
@ -7,7 +7,7 @@ Please see LICENSE files in the repository root for full details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { MatrixEvent } from "matrix-js-sdk/src/matrix";
|
import { MatrixEvent, MatrixEventEvent } from "matrix-js-sdk/src/matrix";
|
||||||
|
|
||||||
import RoomContext from "../../../contexts/RoomContext";
|
import RoomContext from "../../../contexts/RoomContext";
|
||||||
import * as TextForEvent from "../../../TextForEvent";
|
import * as TextForEvent from "../../../TextForEvent";
|
||||||
|
@ -21,6 +21,19 @@ export default class TextualEvent extends React.Component<IProps> {
|
||||||
public static contextType = RoomContext;
|
public static contextType = RoomContext;
|
||||||
declare public context: React.ContextType<typeof RoomContext>;
|
declare public context: React.ContextType<typeof RoomContext>;
|
||||||
|
|
||||||
|
public componentDidMount(): void {
|
||||||
|
this.props.mxEvent.on(MatrixEventEvent.SentinelUpdated, this.onEventSentinelUpdated);
|
||||||
|
}
|
||||||
|
public componentWillUnmount(): void {
|
||||||
|
this.props.mxEvent.off(MatrixEventEvent.SentinelUpdated, this.onEventSentinelUpdated);
|
||||||
|
}
|
||||||
|
|
||||||
|
private onEventSentinelUpdated = (): void => {
|
||||||
|
// XXX: this is crap, but we don't have a better way to force a re-render
|
||||||
|
// Many TextForEvent handlers render parts of `event.sender` and `event.target` so ensure they are updated
|
||||||
|
this.forceUpdate();
|
||||||
|
};
|
||||||
|
|
||||||
public render(): React.ReactNode {
|
public render(): React.ReactNode {
|
||||||
const text = TextForEvent.textForEvent(
|
const text = TextForEvent.textForEvent(
|
||||||
this.props.mxEvent,
|
this.props.mxEvent,
|
||||||
|
|
Loading…
Reference in New Issue