fix ram cache not sending null on empty messages

also fixed ram cache "most recent" messages selection bug
This commit is contained in:
Michael Peters 2021-12-01 21:13:01 -06:00
parent cde18a28b3
commit 1ec5a5dac1

View File

@ -89,6 +89,10 @@ export default class MessageRAMCache {
value.lastUsed = new Date();
let allRecentMessages = Array.from(value.messages.values()).sort((a, b) => a.sent.getTime() - b.sent.getTime());
let start = Math.min(allRecentMessages.length - number, 0);
return allRecentMessages.slice(start, 0);
let result = allRecentMessages.slice(start);
if (result.length === 0) {
return null;
}
return result;
}
}