1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-09-01 21:21:58 +03:00

Emit events for read receipts

This commit is contained in:
David Baker
2015-11-03 11:43:52 +00:00
parent c6aac8cbd9
commit 142ee81e66
2 changed files with 16 additions and 1 deletions

View File

@@ -2466,7 +2466,7 @@ function createNewUser(client, userId) {
function createNewRoom(client, roomId) {
var room = new Room(roomId);
reEmit(client, room, ["Room.name", "Room.timeline"]);
reEmit(client, room, ["Room.name", "Room.timeline", "Room.receipt"]);
// we need to also re-emit room state and room member events, so hook it up
// to the client now. We need to add a listener for RoomState.members in

View File

@@ -399,6 +399,10 @@ Room.prototype.addReceipt = function(event) {
});
});
});
// send events after we've regenerated the cache, otherwise things that
// listened for the event would read from a stale cache
this.emit("Room.receipt", event, this);
};
function setEventMetadata(event, stateContext, toStartOfTimeline) {
@@ -527,3 +531,14 @@ module.exports = Room;
* var newName = room.name;
* });
*/
/**
* Fires whenever a receipt is received for a room
* @event module:client~MatrixClient#"Room.receipt"
* @param {event} event The receipt event
* @param {Room} room The room whose Room.name was updated.
* @example
* matrixClient.on("Room.receipt", function(event, room){
* var receiptContent = event.getContent();
* });
*/