mirror of
https://github.com/element-hq/element-web
synced 2024-11-24 10:15:43 +03:00
Merge pull request #5360 from matrix-org/t3chguy/fix/15586
Watch replyToEvent at RoomView to prevent races
This commit is contained in:
commit
3c9cc636c4
2 changed files with 5 additions and 15 deletions
|
@ -129,6 +129,7 @@ export interface IState {
|
||||||
initialEventPixelOffset?: number;
|
initialEventPixelOffset?: number;
|
||||||
// Whether to highlight the event scrolled to
|
// Whether to highlight the event scrolled to
|
||||||
isInitialEventHighlighted?: boolean;
|
isInitialEventHighlighted?: boolean;
|
||||||
|
replyToEvent?: MatrixEvent;
|
||||||
forwardingEvent?: MatrixEvent;
|
forwardingEvent?: MatrixEvent;
|
||||||
numUnreadMessages: number;
|
numUnreadMessages: number;
|
||||||
draggingFile: boolean;
|
draggingFile: boolean;
|
||||||
|
@ -315,6 +316,7 @@ export default class RoomView extends React.Component<IProps, IState> {
|
||||||
joining: RoomViewStore.isJoining(),
|
joining: RoomViewStore.isJoining(),
|
||||||
initialEventId: RoomViewStore.getInitialEventId(),
|
initialEventId: RoomViewStore.getInitialEventId(),
|
||||||
isInitialEventHighlighted: RoomViewStore.isInitialEventHighlighted(),
|
isInitialEventHighlighted: RoomViewStore.isInitialEventHighlighted(),
|
||||||
|
replyToEvent: RoomViewStore.getQuotingEvent(),
|
||||||
forwardingEvent: RoomViewStore.getForwardingEvent(),
|
forwardingEvent: RoomViewStore.getForwardingEvent(),
|
||||||
// we should only peek once we have a ready client
|
// we should only peek once we have a ready client
|
||||||
shouldPeek: this.state.matrixClientIsReady && RoomViewStore.shouldPeek(),
|
shouldPeek: this.state.matrixClientIsReady && RoomViewStore.shouldPeek(),
|
||||||
|
@ -1899,6 +1901,7 @@ export default class RoomView extends React.Component<IProps, IState> {
|
||||||
showApps={this.state.showApps}
|
showApps={this.state.showApps}
|
||||||
e2eStatus={this.state.e2eStatus}
|
e2eStatus={this.state.e2eStatus}
|
||||||
resizeNotifier={this.props.resizeNotifier}
|
resizeNotifier={this.props.resizeNotifier}
|
||||||
|
replyToEvent={this.state.replyToEvent}
|
||||||
permalinkCreator={this.getPermalinkCreatorForRoom(this.state.room)}
|
permalinkCreator={this.getPermalinkCreatorForRoom(this.state.room)}
|
||||||
/>;
|
/>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ import CallHandler from '../../../CallHandler';
|
||||||
import {MatrixClientPeg} from '../../../MatrixClientPeg';
|
import {MatrixClientPeg} from '../../../MatrixClientPeg';
|
||||||
import * as sdk from '../../../index';
|
import * as sdk from '../../../index';
|
||||||
import dis from '../../../dispatcher/dispatcher';
|
import dis from '../../../dispatcher/dispatcher';
|
||||||
import RoomViewStore from '../../../stores/RoomViewStore';
|
|
||||||
import Stickerpicker from './Stickerpicker';
|
import Stickerpicker from './Stickerpicker';
|
||||||
import { makeRoomPermalink } from '../../../utils/permalinks/Permalinks';
|
import { makeRoomPermalink } from '../../../utils/permalinks/Permalinks';
|
||||||
import ContentMessages from '../../../ContentMessages';
|
import ContentMessages from '../../../ContentMessages';
|
||||||
|
@ -254,7 +253,6 @@ export default class MessageComposer extends React.Component {
|
||||||
super(props);
|
super(props);
|
||||||
this.onInputStateChanged = this.onInputStateChanged.bind(this);
|
this.onInputStateChanged = this.onInputStateChanged.bind(this);
|
||||||
this._onRoomStateEvents = this._onRoomStateEvents.bind(this);
|
this._onRoomStateEvents = this._onRoomStateEvents.bind(this);
|
||||||
this._onRoomViewStoreUpdate = this._onRoomViewStoreUpdate.bind(this);
|
|
||||||
this._onTombstoneClick = this._onTombstoneClick.bind(this);
|
this._onTombstoneClick = this._onTombstoneClick.bind(this);
|
||||||
this.renderPlaceholderText = this.renderPlaceholderText.bind(this);
|
this.renderPlaceholderText = this.renderPlaceholderText.bind(this);
|
||||||
WidgetStore.instance.on(UPDATE_EVENT, this._onWidgetUpdate);
|
WidgetStore.instance.on(UPDATE_EVENT, this._onWidgetUpdate);
|
||||||
|
@ -262,7 +260,6 @@ export default class MessageComposer extends React.Component {
|
||||||
this._dispatcherRef = null;
|
this._dispatcherRef = null;
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
replyToEvent: RoomViewStore.getQuotingEvent(),
|
|
||||||
tombstone: this._getRoomTombstone(),
|
tombstone: this._getRoomTombstone(),
|
||||||
canSendMessages: this.props.room.maySendMessage(),
|
canSendMessages: this.props.room.maySendMessage(),
|
||||||
showCallButtons: SettingsStore.getValue("showCallButtonsInComposer"),
|
showCallButtons: SettingsStore.getValue("showCallButtonsInComposer"),
|
||||||
|
@ -294,7 +291,6 @@ export default class MessageComposer extends React.Component {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.dispatcherRef = dis.register(this.onAction);
|
this.dispatcherRef = dis.register(this.onAction);
|
||||||
MatrixClientPeg.get().on("RoomState.events", this._onRoomStateEvents);
|
MatrixClientPeg.get().on("RoomState.events", this._onRoomStateEvents);
|
||||||
this._roomStoreToken = RoomViewStore.addListener(this._onRoomViewStoreUpdate);
|
|
||||||
this._waitForOwnMember();
|
this._waitForOwnMember();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,9 +314,6 @@ export default class MessageComposer extends React.Component {
|
||||||
if (MatrixClientPeg.get()) {
|
if (MatrixClientPeg.get()) {
|
||||||
MatrixClientPeg.get().removeListener("RoomState.events", this._onRoomStateEvents);
|
MatrixClientPeg.get().removeListener("RoomState.events", this._onRoomStateEvents);
|
||||||
}
|
}
|
||||||
if (this._roomStoreToken) {
|
|
||||||
this._roomStoreToken.remove();
|
|
||||||
}
|
|
||||||
WidgetStore.instance.removeListener(UPDATE_EVENT, this._onWidgetUpdate);
|
WidgetStore.instance.removeListener(UPDATE_EVENT, this._onWidgetUpdate);
|
||||||
ActiveWidgetStore.removeListener('update', this._onActiveWidgetUpdate);
|
ActiveWidgetStore.removeListener('update', this._onActiveWidgetUpdate);
|
||||||
dis.unregister(this.dispatcherRef);
|
dis.unregister(this.dispatcherRef);
|
||||||
|
@ -341,12 +334,6 @@ export default class MessageComposer extends React.Component {
|
||||||
return this.props.room.currentState.getStateEvents('m.room.tombstone', '');
|
return this.props.room.currentState.getStateEvents('m.room.tombstone', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
_onRoomViewStoreUpdate() {
|
|
||||||
const replyToEvent = RoomViewStore.getQuotingEvent();
|
|
||||||
if (this.state.replyToEvent === replyToEvent) return;
|
|
||||||
this.setState({ replyToEvent });
|
|
||||||
}
|
|
||||||
|
|
||||||
onInputStateChanged(inputState) {
|
onInputStateChanged(inputState) {
|
||||||
// Merge the new input state with old to support partial updates
|
// Merge the new input state with old to support partial updates
|
||||||
inputState = Object.assign({}, this.state.inputState, inputState);
|
inputState = Object.assign({}, this.state.inputState, inputState);
|
||||||
|
@ -383,7 +370,7 @@ export default class MessageComposer extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
renderPlaceholderText() {
|
renderPlaceholderText() {
|
||||||
if (this.state.replyToEvent) {
|
if (this.props.replyToEvent) {
|
||||||
if (this.props.e2eStatus) {
|
if (this.props.e2eStatus) {
|
||||||
return _t('Send an encrypted reply…');
|
return _t('Send an encrypted reply…');
|
||||||
} else {
|
} else {
|
||||||
|
@ -429,7 +416,7 @@ export default class MessageComposer extends React.Component {
|
||||||
placeholder={this.renderPlaceholderText()}
|
placeholder={this.renderPlaceholderText()}
|
||||||
resizeNotifier={this.props.resizeNotifier}
|
resizeNotifier={this.props.resizeNotifier}
|
||||||
permalinkCreator={this.props.permalinkCreator}
|
permalinkCreator={this.props.permalinkCreator}
|
||||||
replyToEvent={this.state.replyToEvent}
|
replyToEvent={this.props.replyToEvent}
|
||||||
/>,
|
/>,
|
||||||
<UploadButton key="controls_upload" roomId={this.props.room.roomId} />,
|
<UploadButton key="controls_upload" roomId={this.props.room.roomId} />,
|
||||||
<EmojiButton key="emoji_button" addEmoji={this.addEmoji} />,
|
<EmojiButton key="emoji_button" addEmoji={this.addEmoji} />,
|
||||||
|
|
Loading…
Reference in a new issue