From 40d113a423283f71515d84808fc817ed6cc467f6 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 16 Oct 2015 11:54:47 +0100 Subject: [PATCH] Pass in receipts from initialSync --- lib/client.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/client.js b/lib/client.js index ea7aee9cb..87476d6c8 100644 --- a/lib/client.js +++ b/lib/client.js @@ -1903,6 +1903,19 @@ function doInitialSync(client, historyLen) { user.setPresenceEvent(e); client.store.storeUser(user); }); + + // group receipts by room ID. + var receiptsByRoom = {}; + data.receipts = data.receipts || []; + utils.forEach(data.receipts.map(_PojoToMatrixEventMapper(client)), + function(receiptEvent) { + if (!receiptsByRoom[receiptEvent.getRoomId()]) { + receiptsByRoom[receiptEvent.getRoomId()] = []; + } + receiptsByRoom[receiptEvent.getRoomId()].push(receiptEvent); + } + ); + for (i = 0; i < data.rooms.length; i++) { var room = createNewRoom(client, data.rooms[i].room_id); if (!data.rooms[i].state) { @@ -1926,6 +1939,11 @@ function doInitialSync(client, historyLen) { client, room, data.rooms[i].state, data.rooms[i].messages ); + var receipts = receiptsByRoom[room.roomId] || []; + for (j = 0; j < receipts.length; j++) { + room.addReceipt(receipts[j]); + } + // cache the name/summary/etc prior to storage since we don't // know how the store will serialise the Room. room.recalculate(client.credentials.userId);