-
-
Notifications
You must be signed in to change notification settings - Fork 582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add function to determine who has read at least a given event #1625
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm being cautious on this, as I'd like to work out if there's any possible way to do less work to support the use case.
const events = this.getLiveTimeline().getEvents(); // timelines are most recent last | ||
let foundEvent = false; | ||
const receiptIds = new Set(); | ||
for (let i = events.length - 1; i >= Math.max(0, events.length - maxEvents); i--) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This loop feels kind of wasteful given that TimelinePanel
/ MessagePanel
already did a very similar scan to construct the EventTile
... Anyway, mostly just an idle thought, as I guess you'd need to restructure lots of things for it to be more efficient.
* @param {number} maxEvents The maximum number of events to search within. | ||
* @returns {string[]} A list of user IDs who have read the event. | ||
*/ | ||
Room.prototype.getUsersWhoHaveRead = function(event, maxEvents) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you want this API to collect all users who have read the event? In the one caller so far, you actually only care if someone has read it (other than yourself), but the actual list of senders goes unused... Is there a plan to use it in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's largely the balance of usefulness and API scope. We could add a hasAnyoneRead
function, but the react SDK would be the only consumer. In this approach, we're adding something theoretically useful for other applications, and maybe even ourselves if we decide to add a "who has read this" API.
Ideally this whole problem is solved by matrix rather than a loop in our code, but this is the first time we've needed a different kind of receipt calculation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, let's go with this for now.
This ultimately isn't used. |
Required by matrix-org/matrix-react-sdk#5699