fix ram cache not sending null on empty messages
also fixed ram cache "most recent" messages selection bug
This commit is contained in:
parent
cde18a28b3
commit
1ec5a5dac1
@ -89,6 +89,10 @@ export default class MessageRAMCache {
|
|||||||
value.lastUsed = new Date();
|
value.lastUsed = new Date();
|
||||||
let allRecentMessages = Array.from(value.messages.values()).sort((a, b) => a.sent.getTime() - b.sent.getTime());
|
let allRecentMessages = Array.from(value.messages.values()).sort((a, b) => a.sent.getTime() - b.sent.getTime());
|
||||||
let start = Math.min(allRecentMessages.length - number, 0);
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user