From 1ec5a5dac158dc3350c42811eb47634fea69b0e6 Mon Sep 17 00:00:00 2001 From: Michael Peters Date: Wed, 1 Dec 2021 21:13:01 -0600 Subject: [PATCH] fix ram cache not sending null on empty messages also fixed ram cache "most recent" messages selection bug --- client/webapp/message-ram-cache.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/webapp/message-ram-cache.ts b/client/webapp/message-ram-cache.ts index cca7d62..d028f0a 100644 --- a/client/webapp/message-ram-cache.ts +++ b/client/webapp/message-ram-cache.ts @@ -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; } } \ No newline at end of file