From 59b812b4e35c18e7cbde970b94e90c8597248c1d Mon Sep 17 00:00:00 2001 From: Vincent TE Date: Tue, 13 Aug 2024 10:15:36 +0200 Subject: [PATCH] Code review --- app/src/main/java/com/infomaniak/mail/ui/MainViewModel.kt | 2 +- .../main/thread/actions/DownloadAttachmentProgressDialog.kt | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/infomaniak/mail/ui/MainViewModel.kt b/app/src/main/java/com/infomaniak/mail/ui/MainViewModel.kt index 7a88011c91..78c5813ce0 100644 --- a/app/src/main/java/com/infomaniak/mail/ui/MainViewModel.kt +++ b/app/src/main/java/com/infomaniak/mail/ui/MainViewModel.kt @@ -179,7 +179,7 @@ class MainViewModel @Inject constructor( .stateIn( scope = viewModelScope, started = SharingStarted.Eagerly, - initialValue = null + initialValue = null, ) private var currentThreadsLiveJob: Job? = null diff --git a/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/DownloadAttachmentProgressDialog.kt b/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/DownloadAttachmentProgressDialog.kt index 1cc1dad341..342e7667f1 100644 --- a/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/DownloadAttachmentProgressDialog.kt +++ b/app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/DownloadAttachmentProgressDialog.kt @@ -79,12 +79,9 @@ class DownloadAttachmentProgressDialog : DialogFragment() { } private fun popBackStackWithError() { - // We have to use the Flow instead of the LiveData here since the mainViewModel is not the same instance as the one in the - // MainActivity. So, instead of observing the LiveData in order to make it "active", we use the Flow. viewLifecycleOwner.lifecycleScope.launch { mainViewModel.isNetworkAvailable.first { it != null }?.let { isNetworkAvailable -> - val title = if (isNetworkAvailable) R.string.anErrorHasOccurred else R.string.noConnection - showSnackbar(title) + showSnackbar(if (isNetworkAvailable) R.string.anErrorHasOccurred else R.string.noConnection) findNavController().popBackStack() } }