Implement changes to MSC2285 (private read receipts) (#7993)
This commit is contained in:
parent
eca8494c66
commit
99543a7858
4 changed files with 16 additions and 9 deletions
|
@ -23,6 +23,7 @@ import { MatrixEvent } from 'matrix-js-sdk/src/models/event';
|
|||
import { Relations } from "matrix-js-sdk/src/models/relations";
|
||||
import { logger } from 'matrix-js-sdk/src/logger';
|
||||
import { RoomStateEvent } from "matrix-js-sdk/src/models/room-state";
|
||||
import { ReceiptType } from "matrix-js-sdk/src/@types/read_receipts";
|
||||
import { M_BEACON_INFO } from 'matrix-js-sdk/src/@types/beacon';
|
||||
|
||||
import shouldHideEvent from '../../shouldHideEvent';
|
||||
|
@ -847,7 +848,7 @@ export default class MessagePanel extends React.Component<IProps, IState> {
|
|||
}
|
||||
const receipts: IReadReceiptProps[] = [];
|
||||
room.getReceiptsForEvent(event).forEach((r) => {
|
||||
if (!r.userId || r.type !== "m.read" || r.userId === myUserId) {
|
||||
if (!r.userId || ![ReceiptType.Read, ReceiptType.ReadPrivate].includes(r.type) || r.userId === myUserId) {
|
||||
return; // ignore non-read receipts and receipts from self.
|
||||
}
|
||||
if (MatrixClientPeg.get().isUserIgnored(r.userId)) {
|
||||
|
|
|
@ -28,6 +28,7 @@ import { debounce } from 'lodash';
|
|||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { ClientEvent } from "matrix-js-sdk/src/client";
|
||||
import { Thread } from 'matrix-js-sdk/src/models/thread';
|
||||
import { ReceiptType } from "matrix-js-sdk/src/@types/read_receipts";
|
||||
|
||||
import SettingsStore from "../../settings/SettingsStore";
|
||||
import { Layout } from "../../settings/enums/Layout";
|
||||
|
@ -862,14 +863,14 @@ class TimelinePanel extends React.Component<IProps, IState> {
|
|||
MatrixClientPeg.get().setRoomReadMarkers(
|
||||
roomId,
|
||||
this.state.readMarkerEventId,
|
||||
lastReadEvent, // Could be null, in which case no RR is sent
|
||||
{ hidden: hiddenRR },
|
||||
hiddenRR ? null : lastReadEvent, // Could be null, in which case no RR is sent
|
||||
lastReadEvent, // Could be null, in which case no private RR is sent
|
||||
).catch((e) => {
|
||||
// /read_markers API is not implemented on this HS, fallback to just RR
|
||||
if (e.errcode === 'M_UNRECOGNIZED' && lastReadEvent) {
|
||||
return MatrixClientPeg.get().sendReadReceipt(
|
||||
lastReadEvent,
|
||||
{},
|
||||
hiddenRR ? ReceiptType.ReadPrivate : ReceiptType.Read,
|
||||
).catch((e) => {
|
||||
logger.error(e);
|
||||
this.lastRRSentEventId = undefined;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue