mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-22 09:25:49 +03:00
Protect calls to FileService.downloadFile()
This commit is contained in:
parent
2495fa49f3
commit
511a0c22e2
1 changed files with 22 additions and 14 deletions
|
@ -1675,10 +1675,12 @@ class RoomDetailFragment @Inject constructor(
|
|||
shareText(requireContext(), action.messageContent.body)
|
||||
} else if (action.messageContent is MessageWithAttachmentContent) {
|
||||
lifecycleScope.launch {
|
||||
val data = session.fileService().downloadFile(messageContent = action.messageContent)
|
||||
if (isAdded) {
|
||||
shareMedia(requireContext(), data, getMimeTypeFromUri(requireContext(), data.toUri()))
|
||||
}
|
||||
val result = runCatching { session.fileService().downloadFile(messageContent = action.messageContent) }
|
||||
if (!isAdded) return@launch
|
||||
result.fold(
|
||||
{ shareMedia(requireContext(), it, getMimeTypeFromUri(requireContext(), it.toUri())) },
|
||||
{ showErrorInSnackbar(it) }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1701,16 +1703,22 @@ class RoomDetailFragment @Inject constructor(
|
|||
return
|
||||
}
|
||||
lifecycleScope.launch {
|
||||
val data = session.fileService().downloadFile(messageContent = action.messageContent)
|
||||
if (isAdded) {
|
||||
saveMedia(
|
||||
context = requireContext(),
|
||||
file = data,
|
||||
title = action.messageContent.body,
|
||||
mediaMimeType = action.messageContent.mimeType ?: getMimeTypeFromUri(requireContext(), data.toUri()),
|
||||
notificationUtils = notificationUtils
|
||||
)
|
||||
}
|
||||
val result = runCatching { session.fileService().downloadFile(messageContent = action.messageContent) }
|
||||
if (!isAdded) return@launch
|
||||
result.fold(
|
||||
{
|
||||
saveMedia(
|
||||
context = requireContext(),
|
||||
file = it,
|
||||
title = action.messageContent.body,
|
||||
mediaMimeType = action.messageContent.mimeType ?: getMimeTypeFromUri(requireContext(), it.toUri()),
|
||||
notificationUtils = notificationUtils
|
||||
)
|
||||
},
|
||||
{
|
||||
showErrorInSnackbar(it)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue