matrix-js-sdk 15.5.1 → 15.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/browser-matrix.js +31 -19
- package/dist/browser-matrix.js.map +2 -2
- package/dist/browser-matrix.min.js +1 -1
- package/dist/browser-matrix.min.js.map +1 -1
- package/git-revision.txt +1 -1
- package/lib/models/room.d.ts +3 -3
- package/lib/models/room.d.ts.map +1 -1
- package/lib/models/room.js +39 -21
- package/package.json +1 -1
- package/src/models/room.ts +42 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
Changes in [15.5.2](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v15.5.2) (2022-02-17)
|
|
2
|
+
==================================================================================================
|
|
3
|
+
|
|
4
|
+
## 🐛 Bug Fixes
|
|
5
|
+
* Fix synthetic read receipt handling
|
|
6
|
+
|
|
1
7
|
Changes in [15.5.1](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v15.5.1) (2022-02-14)
|
|
2
8
|
==================================================================================================
|
|
3
9
|
|
package/dist/browser-matrix.js
CHANGED
|
@@ -50841,10 +50841,10 @@ class Room extends events_1.EventEmitter {
|
|
|
50841
50841
|
getReadReceiptForUserId(userId, ignoreSynthesized = false) {
|
|
50842
50842
|
var _a, _b;
|
|
50843
50843
|
const [realReceipt, syntheticReceipt] = (_b = (_a = this.receipts["m.read"]) === null || _a === void 0 ? void 0 : _a[userId]) !== null && _b !== void 0 ? _b : [];
|
|
50844
|
-
if (ignoreSynthesized
|
|
50844
|
+
if (ignoreSynthesized) {
|
|
50845
50845
|
return realReceipt;
|
|
50846
50846
|
}
|
|
50847
|
-
return syntheticReceipt;
|
|
50847
|
+
return syntheticReceipt !== null && syntheticReceipt !== void 0 ? syntheticReceipt : realReceipt;
|
|
50848
50848
|
}
|
|
50849
50849
|
/**
|
|
50850
50850
|
* Get the ID of the event that a given user has read up to, or null if we
|
|
@@ -50904,10 +50904,10 @@ class Room extends events_1.EventEmitter {
|
|
|
50904
50904
|
/**
|
|
50905
50905
|
* Add a receipt event to the room.
|
|
50906
50906
|
* @param {MatrixEvent} event The m.receipt event.
|
|
50907
|
-
* @param {Boolean}
|
|
50907
|
+
* @param {Boolean} synthetic True if this event is implicit.
|
|
50908
50908
|
*/
|
|
50909
|
-
addReceipt(event,
|
|
50910
|
-
this.addReceiptsToStructure(event,
|
|
50909
|
+
addReceipt(event, synthetic = false) {
|
|
50910
|
+
this.addReceiptsToStructure(event, synthetic);
|
|
50911
50911
|
// send events after we've regenerated the structure & cache, otherwise things that
|
|
50912
50912
|
// listened for the event would read stale data.
|
|
50913
50913
|
this.emit("Room.receipt", event, this);
|
|
@@ -50915,14 +50915,14 @@ class Room extends events_1.EventEmitter {
|
|
|
50915
50915
|
/**
|
|
50916
50916
|
* Add a receipt event to the room.
|
|
50917
50917
|
* @param {MatrixEvent} event The m.receipt event.
|
|
50918
|
-
* @param {Boolean}
|
|
50918
|
+
* @param {Boolean} synthetic True if this event is implicit.
|
|
50919
50919
|
*/
|
|
50920
|
-
addReceiptsToStructure(event,
|
|
50920
|
+
addReceiptsToStructure(event, synthetic) {
|
|
50921
50921
|
const content = event.getContent();
|
|
50922
50922
|
Object.keys(content).forEach((eventId) => {
|
|
50923
50923
|
Object.keys(content[eventId]).forEach((receiptType) => {
|
|
50924
50924
|
Object.keys(content[eventId][receiptType]).forEach((userId) => {
|
|
50925
|
-
var _a;
|
|
50925
|
+
var _a, _b, _c;
|
|
50926
50926
|
const receipt = content[eventId][receiptType][userId];
|
|
50927
50927
|
if (!this.receipts[receiptType]) {
|
|
50928
50928
|
this.receipts[receiptType] = {};
|
|
@@ -50932,8 +50932,8 @@ class Room extends events_1.EventEmitter {
|
|
|
50932
50932
|
}
|
|
50933
50933
|
const pair = this.receipts[receiptType][userId];
|
|
50934
50934
|
let existingReceipt = pair[ReceiptPairRealIndex];
|
|
50935
|
-
if (
|
|
50936
|
-
existingReceipt = pair[ReceiptPairSyntheticIndex];
|
|
50935
|
+
if (synthetic) {
|
|
50936
|
+
existingReceipt = (_a = pair[ReceiptPairSyntheticIndex]) !== null && _a !== void 0 ? _a : pair[ReceiptPairRealIndex];
|
|
50937
50937
|
}
|
|
50938
50938
|
if (existingReceipt) {
|
|
50939
50939
|
// we only want to add this receipt if we think it is later than the one we already have.
|
|
@@ -50947,8 +50947,28 @@ class Room extends events_1.EventEmitter {
|
|
|
50947
50947
|
eventId,
|
|
50948
50948
|
data: receipt,
|
|
50949
50949
|
};
|
|
50950
|
+
const realReceipt = synthetic ? pair[ReceiptPairRealIndex] : wrappedReceipt;
|
|
50951
|
+
const syntheticReceipt = synthetic ? wrappedReceipt : pair[ReceiptPairSyntheticIndex];
|
|
50952
|
+
let ordering = null;
|
|
50953
|
+
if (realReceipt && syntheticReceipt) {
|
|
50954
|
+
ordering = this.getUnfilteredTimelineSet().compareEventOrdering(realReceipt.eventId, syntheticReceipt.eventId);
|
|
50955
|
+
}
|
|
50956
|
+
const preferSynthetic = ordering === null || ordering < 0;
|
|
50950
50957
|
// we don't bother caching just real receipts by event ID as there's nothing that would read it.
|
|
50951
|
-
|
|
50958
|
+
// Take the current cached receipt before we overwrite the pair elements.
|
|
50959
|
+
const cachedReceipt = (_b = pair[ReceiptPairSyntheticIndex]) !== null && _b !== void 0 ? _b : pair[ReceiptPairRealIndex];
|
|
50960
|
+
if (synthetic && preferSynthetic) {
|
|
50961
|
+
pair[ReceiptPairSyntheticIndex] = wrappedReceipt;
|
|
50962
|
+
}
|
|
50963
|
+
else if (!synthetic) {
|
|
50964
|
+
pair[ReceiptPairRealIndex] = wrappedReceipt;
|
|
50965
|
+
if (!preferSynthetic) {
|
|
50966
|
+
pair[ReceiptPairSyntheticIndex] = null;
|
|
50967
|
+
}
|
|
50968
|
+
}
|
|
50969
|
+
const newCachedReceipt = (_c = pair[ReceiptPairSyntheticIndex]) !== null && _c !== void 0 ? _c : pair[ReceiptPairRealIndex];
|
|
50970
|
+
if (cachedReceipt === newCachedReceipt)
|
|
50971
|
+
return;
|
|
50952
50972
|
// clean up any previous cache entry
|
|
50953
50973
|
if (cachedReceipt && this.receiptCacheByEventId[cachedReceipt.eventId]) {
|
|
50954
50974
|
const previousEventId = cachedReceipt.eventId;
|
|
@@ -50969,14 +50989,6 @@ class Room extends events_1.EventEmitter {
|
|
|
50969
50989
|
type: receiptType,
|
|
50970
50990
|
data: receipt,
|
|
50971
50991
|
});
|
|
50972
|
-
if (fake) {
|
|
50973
|
-
pair[ReceiptPairSyntheticIndex] = wrappedReceipt;
|
|
50974
|
-
}
|
|
50975
|
-
else {
|
|
50976
|
-
pair[ReceiptPairRealIndex] = wrappedReceipt;
|
|
50977
|
-
// a real receipt for a receiptType+userId tuple should clobber any synthetic one
|
|
50978
|
-
pair[ReceiptPairSyntheticIndex] = null;
|
|
50979
|
-
}
|
|
50980
50992
|
});
|
|
50981
50993
|
});
|
|
50982
50994
|
});
|