From ee1c861eb2ba98bf43bd206e4cecaceb3d86cc23 Mon Sep 17 00:00:00 2001 From: Hampus Date: Thu, 8 Oct 2026 03:02:41 +0200 Subject: [PATCH] perf(desktop): cache display media and retain shown images (#3264) --- .../components/embeds/media/EmbedVideo.tsx | 5 +- .../embeds/media/VoiceMessagePlayer.tsx | 3 +- .../components/modals/ImageCropModal.tsx | 5 +- .../messaging/utils/DesktopResourceUrl.ts | 39 ++++++++++++ .../messaging/utils/ImageCacheUtils.ts | 2 + .../messaging/utils/ImageRetention.ts | 44 ++++++++++++++ .../utils/MediaProxyUtils.desktop.test.ts | 60 +++++++++++++++++++ .../messaging/utils/MediaProxyUtils.ts | 12 ++-- .../ui/action_menu/items/MediaMenuData.tsx | 2 +- .../media_player/components/AudioPlayer.tsx | 3 +- .../components/InlineAudioPlayer.tsx | 5 +- .../media_player/components/VideoPlayer.tsx | 5 +- .../components/modals/MobileVideoViewer.tsx | 3 +- fluxer_app/src/index.tsx | 2 + 14 files changed, 172 insertions(+), 18 deletions(-) create mode 100644 fluxer_app/src/features/messaging/utils/ImageRetention.ts create mode 100644 fluxer_app/src/features/messaging/utils/MediaProxyUtils.desktop.test.ts diff --git a/fluxer_app/src/features/channel/components/embeds/media/EmbedVideo.tsx b/fluxer_app/src/features/channel/components/embeds/media/EmbedVideo.tsx index 2391e9531..c8e27e759 100644 --- a/fluxer_app/src/features/channel/components/embeds/media/EmbedVideo.tsx +++ b/fluxer_app/src/features/channel/components/embeds/media/EmbedVideo.tsx @@ -22,6 +22,7 @@ import {useDeleteAttachment} from '@app/features/messaging/hooks/useDeleteAttach import {useMatureMedia} from '@app/features/messaging/hooks/useMatureMedia'; import {useMediaFavorite} from '@app/features/messaging/hooks/useMediaFavorite'; import {useNearViewport} from '@app/features/messaging/hooks/useNearViewport'; +import {resolveDesktopCrossOriginMediaURL} from '@app/features/messaging/utils/DesktopResourceUrl'; import {createDownloadHandler} from '@app/features/messaging/utils/FileDownloadUtils'; import * as ImageCacheUtils from '@app/features/messaging/utils/ImageCacheUtils'; import {buildMediaProxyURL, mediaDevicePixelRatio} from '@app/features/messaging/utils/MediaProxyUtils'; @@ -575,7 +576,7 @@ const EmbedVideo: FC = observer( muted playsInline preload="metadata" - src={effectiveSrc} + src={resolveDesktopCrossOriginMediaURL(effectiveSrc)} tabIndex={-1} onLoadedMetadata={handleMetadataProbeLoaded} data-flx="channel.embeds.media.embed-video.metadata-probe" @@ -609,7 +610,7 @@ const EmbedVideo: FC = observer(