perf: performance improvements 1
This commit is contained in:
+37
@@ -7,6 +7,7 @@ import {
|
||||
import {
|
||||
buildAttachmentDisplayPinKey,
|
||||
canRevokeAttachmentDisplayBlob,
|
||||
collectMessageIdsForInactiveRoomBlobRelease,
|
||||
shouldRevokeDisplayBlobForAttachment
|
||||
} from './attachment-blob-eviction.rules';
|
||||
|
||||
@@ -58,4 +59,40 @@ describe('attachment-blob-eviction rules', () => {
|
||||
|
||||
expect(shouldRevokeDisplayBlobForAttachment('msg-1', attachment, new Set())).toBe(true);
|
||||
});
|
||||
|
||||
describe('collectMessageIdsForInactiveRoomBlobRelease', () => {
|
||||
const messageRoomIds = new Map([
|
||||
['msg-a', 'room-1'],
|
||||
['msg-b', 'room-2'],
|
||||
['msg-c', 'room-2']
|
||||
]);
|
||||
|
||||
it('selects messages that belong to rooms other than the active one', () => {
|
||||
expect(collectMessageIdsForInactiveRoomBlobRelease(
|
||||
[
|
||||
'msg-a',
|
||||
'msg-b',
|
||||
'msg-c'
|
||||
],
|
||||
(messageId) => messageRoomIds.get(messageId) ?? null,
|
||||
'room-1'
|
||||
)).toEqual(['msg-b', 'msg-c']);
|
||||
});
|
||||
|
||||
it('skips messages with an unknown room so they are not evicted by mistake', () => {
|
||||
expect(collectMessageIdsForInactiveRoomBlobRelease(
|
||||
['msg-a', 'msg-unknown'],
|
||||
(messageId) => messageRoomIds.get(messageId) ?? null,
|
||||
'room-2'
|
||||
)).toEqual(['msg-a']);
|
||||
});
|
||||
|
||||
it('selects every known-room message when no room is active', () => {
|
||||
expect(collectMessageIdsForInactiveRoomBlobRelease(
|
||||
['msg-a', 'msg-b'],
|
||||
(messageId) => messageRoomIds.get(messageId) ?? null,
|
||||
null
|
||||
)).toEqual(['msg-a', 'msg-b']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user