Merge pull request #5944 from matrix-org/t3chguy/fix/17043

Inhibit sending RR when context switching to a room
This commit is contained in:
Michael Telatynski 2021-04-30 15:13:18 +01:00 committed by GitHub
commit 8dbcc85249
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 2 deletions

View file

@ -190,6 +190,9 @@ export interface IState {
rejectError?: Error; rejectError?: Error;
hasPinnedWidgets?: boolean; hasPinnedWidgets?: boolean;
dragCounter: number; dragCounter: number;
// whether or not a spaces context switch brought us here,
// if it did we don't want the room to be marked as read as soon as it is loaded.
wasContextSwitch?: boolean;
} }
@replaceableComponent("structures.RoomView") @replaceableComponent("structures.RoomView")
@ -326,6 +329,7 @@ export default class RoomView extends React.Component<IProps, IState> {
shouldPeek: this.state.matrixClientIsReady && RoomViewStore.shouldPeek(), shouldPeek: this.state.matrixClientIsReady && RoomViewStore.shouldPeek(),
showingPinned: SettingsStore.getValue("PinnedEvents.isOpen", roomId), showingPinned: SettingsStore.getValue("PinnedEvents.isOpen", roomId),
showReadReceipts: SettingsStore.getValue("showReadReceipts", roomId), showReadReceipts: SettingsStore.getValue("showReadReceipts", roomId),
wasContextSwitch: RoomViewStore.getWasContextSwitch(),
}; };
if (!initial && this.state.shouldPeek && !newState.shouldPeek) { if (!initial && this.state.shouldPeek && !newState.shouldPeek) {
@ -2014,6 +2018,7 @@ export default class RoomView extends React.Component<IProps, IState> {
timelineSet={this.state.room.getUnfilteredTimelineSet()} timelineSet={this.state.room.getUnfilteredTimelineSet()}
showReadReceipts={this.state.showReadReceipts} showReadReceipts={this.state.showReadReceipts}
manageReadReceipts={!this.state.isPeeking} manageReadReceipts={!this.state.isPeeking}
sendReadReceiptOnLoad={!this.state.wasContextSwitch}
manageReadMarkers={!this.state.isPeeking} manageReadMarkers={!this.state.isPeeking}
hidden={hideMessagePanel} hidden={hideMessagePanel}
highlightedEventId={highlightedEventId} highlightedEventId={highlightedEventId}

View file

@ -68,6 +68,7 @@ class TimelinePanel extends React.Component {
showReadReceipts: PropTypes.bool, showReadReceipts: PropTypes.bool,
// Enable managing RRs and RMs. These require the timelineSet to have a room. // Enable managing RRs and RMs. These require the timelineSet to have a room.
manageReadReceipts: PropTypes.bool, manageReadReceipts: PropTypes.bool,
sendReadReceiptOnLoad: PropTypes.bool,
manageReadMarkers: PropTypes.bool, manageReadMarkers: PropTypes.bool,
// true to give the component a 'display: none' style. // true to give the component a 'display: none' style.
@ -126,6 +127,7 @@ class TimelinePanel extends React.Component {
// event tile heights. (See _unpaginateEvents) // event tile heights. (See _unpaginateEvents)
timelineCap: Number.MAX_VALUE, timelineCap: Number.MAX_VALUE,
className: 'mx_RoomView_messagePanel', className: 'mx_RoomView_messagePanel',
sendReadReceiptOnLoad: true,
}; };
constructor(props) { constructor(props) {
@ -1051,7 +1053,9 @@ class TimelinePanel extends React.Component {
this._messagePanel.current.scrollToBottom(); this._messagePanel.current.scrollToBottom();
} }
this.sendReadReceipt(); if (this.props.sendReadReceiptOnLoad) {
this.sendReadReceipt();
}
}); });
}; };

View file

@ -62,6 +62,8 @@ const INITIAL_STATE = {
shouldPeek: false, shouldPeek: false,
viaServers: [], viaServers: [],
wasContextSwitch: false,
}; };
/** /**
@ -116,6 +118,7 @@ class RoomViewStore extends Store<ActionPayload> {
roomId: null, roomId: null,
roomAlias: null, roomAlias: null,
viaServers: [], viaServers: [],
wasContextSwitch: false,
}); });
break; break;
case 'view_room_error': case 'view_room_error':
@ -195,6 +198,7 @@ class RoomViewStore extends Store<ActionPayload> {
// pull the user out of Room Settings // pull the user out of Room Settings
isEditingSettings: false, isEditingSettings: false,
viaServers: payload.via_servers, viaServers: payload.via_servers,
wasContextSwitch: payload.context_switch,
}; };
// Allow being given an event to be replied to when switching rooms but sanity check its for this room // Allow being given an event to be replied to when switching rooms but sanity check its for this room
@ -231,6 +235,7 @@ class RoomViewStore extends Store<ActionPayload> {
roomLoading: true, roomLoading: true,
roomLoadError: null, roomLoadError: null,
viaServers: payload.via_servers, viaServers: payload.via_servers,
wasContextSwitch: payload.context_switch,
}); });
try { try {
const result = await MatrixClientPeg.get().getRoomIdForAlias(payload.room_alias); const result = await MatrixClientPeg.get().getRoomIdForAlias(payload.room_alias);
@ -256,6 +261,8 @@ class RoomViewStore extends Store<ActionPayload> {
room_alias: payload.room_alias, room_alias: payload.room_alias,
auto_join: payload.auto_join, auto_join: payload.auto_join,
oob_data: payload.oob_data, oob_data: payload.oob_data,
viaServers: payload.via_servers,
wasContextSwitch: payload.context_switch,
}); });
} }
} }
@ -266,7 +273,6 @@ class RoomViewStore extends Store<ActionPayload> {
roomAlias: payload.room_alias, roomAlias: payload.room_alias,
roomLoading: false, roomLoading: false,
roomLoadError: payload.err, roomLoadError: payload.err,
viaServers: [],
}); });
} }
@ -426,6 +432,10 @@ class RoomViewStore extends Store<ActionPayload> {
public shouldPeek() { public shouldPeek() {
return this.state.shouldPeek; return this.state.shouldPeek;
} }
public getWasContextSwitch() {
return this.state.wasContextSwitch;
}
} }
let singletonRoomViewStore = null; let singletonRoomViewStore = null;