Add some debugging around the recently DM'd users

The suggestions are relatively stable, but the recents have some issues. Adding logging to the suggestions would also destroy the console log with thousands of messages whereas recents aren't too bad.
This commit is contained in:
Travis Ralston 2020-01-23 17:35:36 -07:00
parent 442ab9f301
commit 32f9a4e623

View file

@ -338,19 +338,31 @@ export default class InviteDialog extends React.PureComponent {
const recents = []; const recents = [];
for (const userId in rooms) { for (const userId in rooms) {
// Filter out user IDs that are already in the room / should be excluded // Filter out user IDs that are already in the room / should be excluded
if (excludedTargetIds.includes(userId)) continue; if (excludedTargetIds.includes(userId)) {
console.warn(`[Invite:Recents] Excluding ${userId} from recents`);
continue;
}
const room = rooms[userId]; const room = rooms[userId];
const member = room.getMember(userId); const member = room.getMember(userId);
if (!member) continue; // just skip people who don't have memberships for some reason if (!member) {
// just skip people who don't have memberships for some reason
console.warn(`[Invite:Recents] ${userId} is missing a member object in their own DM (${room.roomId})`);
continue;
}
const lastEventTs = room.timeline && room.timeline.length const lastEventTs = room.timeline && room.timeline.length
? room.timeline[room.timeline.length - 1].getTs() ? room.timeline[room.timeline.length - 1].getTs()
: 0; : 0;
if (!lastEventTs) continue; // something weird is going on with this room if (!lastEventTs) {
// something weird is going on with this room
console.warn(`[Invite:Recents] ${userId} (${room.roomId}) has a weird last timestamp: ${lastEventTs}`);
continue;
}
recents.push({userId, user: member, lastActive: lastEventTs}); recents.push({userId, user: member, lastActive: lastEventTs});
} }
if (!recents) console.warn("[Invite:Recents] No recents to suggest!");
// Sort the recents by last active to save us time later // Sort the recents by last active to save us time later
recents.sort((a, b) => b.lastActive - a.lastActive); recents.sort((a, b) => b.lastActive - a.lastActive);