Merge pull request #3969 from matrix-org/travis/user-lists/suggestions

Filter event types when deciding on activity metrics for DM suggestions
This commit is contained in:
Travis Ralston 2020-01-29 11:40:32 +00:00 committed by GitHub
commit e200988dbf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -351,9 +351,20 @@ export default class InviteDialog extends React.PureComponent {
continue; continue;
} }
const lastEventTs = room.timeline && room.timeline.length // Find the last timestamp for a message event
? room.timeline[room.timeline.length - 1].getTs() const searchTypes = ["m.room.message", "m.room.encrypted", "m.sticker"];
: 0; const maxSearchEvents = 20; // to prevent traversing history
let lastEventTs = 0;
if (room.timeline && room.timeline.length) {
for (let i = room.timeline.length - 1; i >= 0; i--) {
const ev = room.timeline[i];
if (searchTypes.includes(ev.getType())) {
lastEventTs = ev.getTs();
break;
}
if (room.timeline.length - i > maxSearchEvents) break;
}
}
if (!lastEventTs) { if (!lastEventTs) {
// something weird is going on with this room // something weird is going on with this room
console.warn(`[Invite:Recents] ${userId} (${room.roomId}) has a weird last timestamp: ${lastEventTs}`); console.warn(`[Invite:Recents] ${userId} (${room.roomId}) has a weird last timestamp: ${lastEventTs}`);