From e5abb2e0898306c537b9e02bb8e606ce2ef6be0e Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Tue, 4 Jun 2019 11:12:52 +0100 Subject: [PATCH] Add more read receipt comments --- src/components/structures/MessagePanel.js | 25 +++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/components/structures/MessagePanel.js b/src/components/structures/MessagePanel.js index 1e7e8f3a6e..d290efb1a4 100644 --- a/src/components/structures/MessagePanel.js +++ b/src/components/structures/MessagePanel.js @@ -115,16 +115,37 @@ module.exports = React.createClass({ // to manage its animations this._readReceiptMap = {}; + // Track read receipts by event ID. For each _shown_ event ID, we store + // the list of read receipts to display: + // [ + // { + // userId: string, + // member: RoomMember, + // ts: number, + // }, + // ] + // This is recomputed on each render. It's only stored on the component + // for ease of passing the data around since it's computed in one pass + // over all events. + this._readReceiptsByEvent = {}; + // Track read receipts by user ID. For each user ID we've ever shown a // a read receipt for, we store an object: // { - // lastShownEventId, - // receipt, + // lastShownEventId: string, + // receipt: { + // userId: string, + // member: RoomMember, + // ts: number, + // }, // } // so that we can always keep receipts displayed by reverting back to // the last shown event for that user ID when needed. This may feel like // it duplicates the receipt storage in the room, but at this layer, we // are tracking _shown_ event IDs, which the JS SDK knows nothing about. + // This is recomputed on each render, using the data from the previous + // render as our fallback for any user IDs we can't match a receipt to a + // displayed event in the current render cycle. this._readReceiptsByUserId = {}; // Remember the read marker ghost node so we can do the cleanup that