Fix some stuff

This commit is contained in:
Michael Telatynski 2020-08-29 12:51:37 +01:00
parent 34b960d8cb
commit 78812b6f85
9 changed files with 51 additions and 42 deletions

View file

@ -43,8 +43,8 @@ export default class EmbeddedPage extends React.PureComponent {
static contextType = MatrixClientContext; static contextType = MatrixClientContext;
constructor(props) { constructor(props, context) {
super(props); super(props, context);
this._dispatcherRef = null; this._dispatcherRef = null;

View file

@ -42,8 +42,8 @@ export default class RightPanel extends React.Component {
static contextType = MatrixClientContext; static contextType = MatrixClientContext;
constructor(props) { constructor(props, context) {
super(props); super(props, context);
this.state = { this.state = {
phase: this._getPhaseFromProps(), phase: this._getPhaseFromProps(),
isUserPrivilegedInGroup: null, isUserPrivilegedInGroup: null,

View file

@ -99,8 +99,8 @@ export default class RoomView extends React.Component {
static contextType = MatrixClientContext; static contextType = MatrixClientContext;
constructor(props) { constructor(props, context) {
super(props); super(props, context);
const llMembers = this.context.hasLazyLoadMembersEnabled(); const llMembers = this.context.hasLazyLoadMembersEnabled();
this.state = { this.state = {
@ -186,7 +186,6 @@ export default class RoomView extends React.Component {
// 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);
this._onRoomViewStoreUpdate(true);
WidgetEchoStore.on('update', this._onWidgetEchoStoreUpdate); WidgetEchoStore.on('update', this._onWidgetEchoStoreUpdate);
this._showReadReceiptsWatchRef = SettingsStore.watchSetting("showReadReceipts", null, this._showReadReceiptsWatchRef = SettingsStore.watchSetting("showReadReceipts", null,
@ -198,6 +197,11 @@ export default class RoomView extends React.Component {
this._layoutWatcherRef = SettingsStore.watchSetting("useIRCLayout", null, this.onLayoutChange); this._layoutWatcherRef = SettingsStore.watchSetting("useIRCLayout", null, this.onLayoutChange);
} }
// TODO: [REACT-WARNING] Move into constructor
UNSAFE_componentWillMount() {
this._onRoomViewStoreUpdate(true);
}
_onReadReceiptsChange = () => { _onReadReceiptsChange = () => {
this.setState({ this.setState({
showReadReceipts: SettingsStore.getValue("showReadReceipts", this.state.roomId), showReadReceipts: SettingsStore.getValue("showReadReceipts", this.state.roomId),

View file

@ -134,13 +134,6 @@ class TimelinePanel extends React.Component {
this._messagePanel = createRef(); this._messagePanel = createRef();
if (this.props.manageReadReceipts) {
this.updateReadReceiptOnUserActivity();
}
if (this.props.manageReadMarkers) {
this.updateReadMarkerOnUserActivity();
}
// XXX: we could track RM per TimelineSet rather than per Room. // XXX: we could track RM per TimelineSet rather than per Room.
// but for now we just do it per room for simplicity. // but for now we just do it per room for simplicity.
let initialReadMarker = null; let initialReadMarker = null;
@ -225,6 +218,16 @@ class TimelinePanel extends React.Component {
MatrixClientPeg.get().on("Event.decrypted", this.onEventDecrypted); MatrixClientPeg.get().on("Event.decrypted", this.onEventDecrypted);
MatrixClientPeg.get().on("Event.replaced", this.onEventReplaced); MatrixClientPeg.get().on("Event.replaced", this.onEventReplaced);
MatrixClientPeg.get().on("sync", this.onSync); MatrixClientPeg.get().on("sync", this.onSync);
}
// TODO: [REACT-WARNING] Move into constructor
UNSAFE_componentWillMount() {
if (this.props.manageReadReceipts) {
this.updateReadReceiptOnUserActivity();
}
if (this.props.manageReadMarkers) {
this.updateReadMarkerOnUserActivity();
}
this._initTimeline(this.props); this._initTimeline(this.props);
} }
@ -1360,9 +1363,7 @@ class TimelinePanel extends React.Component {
}); });
} }
getRelationsForEvent(...args) { getRelationsForEvent = (...args) => this.props.timelineSet.getRelationsForEvent(...args);
return this.props.timelineSet.getRelationsForEvent(...args);
}
render() { render() {
const MessagePanel = sdk.getComponent("structures.MessagePanel"); const MessagePanel = sdk.getComponent("structures.MessagePanel");

View file

@ -45,8 +45,8 @@ export default class ReplyThread extends React.Component {
static contextType = MatrixClientContext; static contextType = MatrixClientContext;
constructor(props) { constructor(props, context) {
super(props); super(props, context);
this.state = { this.state = {
// The loaded events to be rendered as linear-replies // The loaded events to be rendered as linear-replies

View file

@ -35,8 +35,8 @@ export default class GroupInviteTile extends React.Component {
static contextType = MatrixClientContext; static contextType = MatrixClientContext;
constructor(props) { constructor(props, context) {
super(props); super(props, context);
this.state = { this.state = {
hover: false, hover: false,

View file

@ -215,8 +215,8 @@ export default class EventTile extends React.Component {
static contextType = MatrixClientContext; static contextType = MatrixClientContext;
constructor(props) { constructor(props, context) {
super(props); super(props, context);
this.state = { this.state = {
// Whether the action bar is focused. // Whether the action bar is focused.
@ -234,12 +234,16 @@ export default class EventTile extends React.Component {
// don't do RR animations until we are mounted // don't do RR animations until we are mounted
this._suppressReadReceiptAnimation = true; this._suppressReadReceiptAnimation = true;
this._verifyEvent(this.props.mxEvent);
this._tile = createRef(); this._tile = createRef();
this._replyThread = createRef(); this._replyThread = createRef();
} }
// TODO: [REACT-WARNING] Move into constructor
UNSAFE_componentWillMount() {
this._verifyEvent(this.props.mxEvent);
}
componentDidMount() { componentDidMount() {
this._suppressReadReceiptAnimation = false; this._suppressReadReceiptAnimation = false;
const client = this.context; const client = this.context;

View file

@ -47,13 +47,6 @@ export default class MemberList extends React.Component {
this.state = this._getMembersState(this.roomMembers()); this.state = this._getMembersState(this.roomMembers());
} }
this._mounted = true;
if (cli.hasLazyLoadMembersEnabled()) {
this._showMembersAccordingToMembershipWithLL();
cli.on("Room.myMembership", this.onMyMembership);
} else {
this._listenForMembersChanges();
}
cli.on("Room", this.onRoom); // invites & joining after peek cli.on("Room", this.onRoom); // invites & joining after peek
const enablePresenceByHsUrl = SdkConfig.get()["enable_presence_by_hs_url"]; const enablePresenceByHsUrl = SdkConfig.get()["enable_presence_by_hs_url"];
const hsUrl = MatrixClientPeg.get().baseUrl; const hsUrl = MatrixClientPeg.get().baseUrl;
@ -63,6 +56,17 @@ export default class MemberList extends React.Component {
} }
} }
componentDidMount() {
const cli = MatrixClientPeg.get();
this._mounted = true;
if (cli.hasLazyLoadMembersEnabled()) {
this._showMembersAccordingToMembershipWithLL();
cli.on("Room.myMembership", this.onMyMembership);
} else {
this._listenForMembersChanges();
}
}
_listenForMembersChanges() { _listenForMembersChanges() {
const cli = MatrixClientPeg.get(); const cli = MatrixClientPeg.get();
cli.on("RoomState.members", this.onRoomStateMember); cli.on("RoomState.members", this.onRoomStateMember);
@ -412,24 +416,20 @@ export default class MemberList extends React.Component {
}); });
} }
_getChildrenJoined(start, end) { _getChildrenJoined = (start, end) => this._makeMemberTiles(this.state.filteredJoinedMembers.slice(start, end));
return this._makeMemberTiles(this.state.filteredJoinedMembers.slice(start, end));
}
_getChildCountJoined() { _getChildCountJoined = () => this.state.filteredJoinedMembers.length;
return this.state.filteredJoinedMembers.length;
}
_getChildrenInvited(start, end) { _getChildrenInvited = (start, end) => {
let targets = this.state.filteredInvitedMembers; let targets = this.state.filteredInvitedMembers;
if (end > this.state.filteredInvitedMembers.length) { if (end > this.state.filteredInvitedMembers.length) {
targets = targets.concat(this._getPending3PidInvites()); targets = targets.concat(this._getPending3PidInvites());
} }
return this._makeMemberTiles(targets.slice(start, end)); return this._makeMemberTiles(targets.slice(start, end));
} };
_getChildCountInvited() { _getChildCountInvited = () => {
return this.state.filteredInvitedMembers.length + (this._getPending3PidInvites() || []).length; return this.state.filteredInvitedMembers.length + (this._getPending3PidInvites() || []).length;
} }

View file

@ -99,8 +99,8 @@ export default class SendMessageComposer extends React.Component {
static contextType = MatrixClientContext; static contextType = MatrixClientContext;
constructor(props) { constructor(props, context) {
super(props); super(props, context);
this.model = null; this.model = null;
this._editorRef = null; this._editorRef = null;
this.currentlyComposedEditorState = null; this.currentlyComposedEditorState = null;