From 3a93e8089eae1733504b84fadd7a46761b98e859 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 7 Oct 2026 17:06:42 +0200 Subject: [PATCH] Get the media optimization config only once when sharing media The config is the same for all the files and all the rooms, so there is no need to read it for each file. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../android/features/share/impl/DefaultShareDataSender.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/features/share/impl/src/main/kotlin/io/element/android/features/share/impl/DefaultShareDataSender.kt b/features/share/impl/src/main/kotlin/io/element/android/features/share/impl/DefaultShareDataSender.kt index 1836bfae10..54085791f6 100644 --- a/features/share/impl/src/main/kotlin/io/element/android/features/share/impl/DefaultShareDataSender.kt +++ b/features/share/impl/src/main/kotlin/io/element/android/features/share/impl/DefaultShareDataSender.kt @@ -50,7 +50,8 @@ class DefaultShareDataSender( if (filesToShare.isEmpty()) { false } else { - val mediaOptimizationConfigProvider = mediaOptimizationConfigProviderFactory.create(client) + // The media optimization config is the same for all the files and all the rooms + val mediaOptimizationConfig = mediaOptimizationConfigProviderFactory.create(client).get() roomIds .map { roomId -> val room = client.findJoinedRoom(roomId) ?: return@map false @@ -61,7 +62,7 @@ class DefaultShareDataSender( caption = shareIntentData.text, uri = fileToShare.uri, mimeType = fileToShare.mimeType, - mediaOptimizationConfig = mediaOptimizationConfigProvider.get(), + mediaOptimizationConfig = mediaOptimizationConfig, ) // If the coroutine was cancelled, destroy the room and rethrow the exception val cancellationException = result.exceptionOrNull() as? CancellationException