@@ -284,38 +284,23 @@ class ThreadController @Inject constructor(
284
284
onUpdate(getThread(threadUid, realm))
285
285
}
286
286
287
- /* *
288
- * Asynchronously fetches heavy data for a list of messages within a given mailbox and realm.
289
- *
290
- * This function fetches heavy data associated with the provided list of messages, such as attachments
291
- * or other resource-intensive content. It operates within the given realm and mailbox context.
292
- *
293
- * This function is deliberately present here as it relies on a method accessible solely through injection.
294
- *
295
- * @param messages List of messages for which heavy data needs to be fetched.
296
- * @param realm The realm context in which the heavy data fetching and updates should occur.
297
- * @param okHttpClient An optional OkHttpClient instance to use for making network requests.
298
- * If not provided, a default client will be used.
299
- */
300
- fun fetchMessagesHeavyData (
301
- messages : List <Message >,
302
- realm : Realm ,
303
- okHttpClient : OkHttpClient ? = null,
304
- ): Pair <List <String >, List<String>> {
305
-
306
- val deletedMessagesUids = mutableListOf<String >()
307
- val failedMessagesUids = mutableListOf<String >()
308
-
309
- fun fetchSwissTransferContainer (uuid : String ): SwissTransferContainer ? = runCatching {
287
+ private fun fetchSwissTransferContainer (uuid : String ): SwissTransferContainer ? {
288
+ return runCatching {
310
289
val apiResponse = ApiRepository .getSwissTransferContainer(uuid)
311
290
312
291
if (apiResponse.isSuccess()) return @runCatching apiResponse.data
313
292
314
293
SentryLog .i(TAG , " Could not fetch SwissTransfer container" )
315
294
return @runCatching null
316
295
}.getOrNull()
296
+ }
317
297
318
- val apiCallsResults = messages.mapNotNull { localMessage ->
298
+ private fun getApiCallsResults (
299
+ messages : List <Message >,
300
+ okHttpClient : OkHttpClient ? ,
301
+ failedMessagesUids : MutableList <String >
302
+ ): List <ApiCallsResults > {
303
+ return messages.mapNotNull { localMessage ->
319
304
return @mapNotNull runCatching {
320
305
val apiResponse = ApiRepository .getMessage(localMessage.resource, okHttpClient)
321
306
val swissTransferUuid = apiResponse.data?.swissTransferUuid
@@ -330,6 +315,31 @@ class ThreadController @Inject constructor(
330
315
return @getOrElse null
331
316
}
332
317
}
318
+ }
319
+
320
+ /* *
321
+ * Asynchronously fetches heavy data for a list of messages within a given mailbox and realm.
322
+ *
323
+ * This function fetches heavy data associated with the provided list of messages, such as attachments
324
+ * or other resource-intensive content. It operates within the given realm and mailbox context.
325
+ *
326
+ * This function is deliberately present here as it relies on a method accessible solely through injection.
327
+ *
328
+ * @param messages List of messages for which heavy data needs to be fetched.
329
+ * @param realm The realm context in which the heavy data fetching and updates should occur.
330
+ * @param okHttpClient An optional OkHttpClient instance to use for making network requests.
331
+ * If not provided, a default client will be used.
332
+ */
333
+ fun fetchMessagesHeavyData (
334
+ messages : List <Message >,
335
+ realm : Realm ,
336
+ okHttpClient : OkHttpClient ? = null,
337
+ ): Pair <List <String >, List<String>> {
338
+
339
+ val deletedMessagesUids = mutableListOf<String >()
340
+ val failedMessagesUids = mutableListOf<String >()
341
+
342
+ val apiCallsResults = getApiCallsResults(messages, okHttpClient, failedMessagesUids)
333
343
334
344
realm.writeBlocking {
335
345
var hasAttachableInThread = false
0 commit comments