Let TimelinePanel not send a receipt if there is no event (#10912)
This commit is contained in:
parent
da0f072ed9
commit
acdbae3e8c
2 changed files with 16 additions and 2 deletions
|
@ -1082,7 +1082,9 @@ class TimelinePanel extends React.Component<IProps, IState> {
|
||||||
currentReadReceiptEventIndex: number | null,
|
currentReadReceiptEventIndex: number | null,
|
||||||
lastReadEvent: MatrixEvent | null,
|
lastReadEvent: MatrixEvent | null,
|
||||||
lastReadEventIndex: number | null,
|
lastReadEventIndex: number | null,
|
||||||
): boolean {
|
): lastReadEvent is MatrixEvent {
|
||||||
|
if (!lastReadEvent) return false;
|
||||||
|
|
||||||
// We want to avoid sending out read receipts when we are looking at
|
// We want to avoid sending out read receipts when we are looking at
|
||||||
// events in the past which are before the latest RR.
|
// events in the past which are before the latest RR.
|
||||||
//
|
//
|
||||||
|
@ -1133,7 +1135,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
|
||||||
const lastReadEventIndex = this.getLastDisplayedEventIndex({
|
const lastReadEventIndex = this.getLastDisplayedEventIndex({
|
||||||
ignoreOwn: true,
|
ignoreOwn: true,
|
||||||
});
|
});
|
||||||
const lastReadEvent: MatrixEvent | null = this.state.events[lastReadEventIndex ?? 0];
|
const lastReadEvent: MatrixEvent | null = this.state.events[lastReadEventIndex ?? 0] ?? null;
|
||||||
|
|
||||||
const shouldSendReadReceipt = this.shouldSendReadReceipt(
|
const shouldSendReadReceipt = this.shouldSendReadReceipt(
|
||||||
currentReadReceiptEventId,
|
currentReadReceiptEventId,
|
||||||
|
|
|
@ -242,6 +242,18 @@ describe("TimelinePanel", () => {
|
||||||
TimelinePanel.roomReadMarkerTsMap = {};
|
TimelinePanel.roomReadMarkerTsMap = {};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("when there is no event, it should not send any receipt", async () => {
|
||||||
|
setUpTimelineSet();
|
||||||
|
await renderTimelinePanel();
|
||||||
|
await flushPromises();
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
await timelinePanel.sendReadReceipts();
|
||||||
|
|
||||||
|
expect(client.setRoomReadMarkers).not.toHaveBeenCalled();
|
||||||
|
expect(client.sendReadReceipt).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
describe("when there is a non-threaded timeline", () => {
|
describe("when there is a non-threaded timeline", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
setUpTimelineSet();
|
setUpTimelineSet();
|
||||||
|
|
Loading…
Reference in a new issue