perf: performance improvements 1
This commit is contained in:
+23
-1
@@ -10,7 +10,11 @@ import { RealtimeSessionFacade } from '../../../../core/realtime';
|
||||
import { selectCurrentUserId } from '../../../../store/users/users.selectors';
|
||||
import { DatabaseService } from '../../../../infrastructure/persistence';
|
||||
import { yieldToAttachmentHydrationLoop } from '../../domain/logic/attachment-blob.rules';
|
||||
import { buildAttachmentDisplayPinKey, shouldRevokeDisplayBlobForAttachment } from '../../domain/logic/attachment-blob-eviction.rules';
|
||||
import {
|
||||
buildAttachmentDisplayPinKey,
|
||||
collectMessageIdsForInactiveRoomBlobRelease,
|
||||
shouldRevokeDisplayBlobForAttachment
|
||||
} from '../../domain/logic/attachment-blob-eviction.rules';
|
||||
import {
|
||||
getWatchedAttachmentRoomIdFromUrl,
|
||||
isDirectMessageAttachmentRoomId,
|
||||
@@ -68,8 +72,14 @@ export class AttachmentManagerService {
|
||||
return;
|
||||
}
|
||||
|
||||
const previousRoomId = this.watchedRoomId;
|
||||
|
||||
this.watchedRoomId = this.extractWatchedRoomId(event.urlAfterRedirects || event.url);
|
||||
|
||||
if (this.watchedRoomId !== previousRoomId) {
|
||||
this.releaseDisplayBlobsForInactiveRooms(this.watchedRoomId);
|
||||
}
|
||||
|
||||
if (this.watchedRoomId) {
|
||||
void this.restoreLocalAttachmentsForRoom(this.watchedRoomId);
|
||||
void this.requestAutoDownloadsForRoom(this.watchedRoomId);
|
||||
@@ -211,6 +221,18 @@ export class AttachmentManagerService {
|
||||
}
|
||||
}
|
||||
|
||||
releaseDisplayBlobsForInactiveRooms(activeRoomId: string | null): void {
|
||||
const messageIds = collectMessageIdsForInactiveRoomBlobRelease(
|
||||
Array.from(this.runtimeStore.getAttachmentEntries(), ([messageId]) => messageId),
|
||||
(messageId) => this.runtimeStore.getMessageRoomId(messageId) ?? null,
|
||||
activeRoomId
|
||||
);
|
||||
|
||||
for (const messageId of messageIds) {
|
||||
this.revokeOffscreenDisplayBlobsForMessage(messageId);
|
||||
}
|
||||
}
|
||||
|
||||
requestFile(messageId: string, attachment: Attachment): Promise<void> {
|
||||
return this.transfer.requestFile(messageId, attachment);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user