From b232ce3650650a2d0da3a1e1ee103e29ded6d2e9 Mon Sep 17 00:00:00 2001 From: iorgamgabriel Date: Fri, 10 Feb 2023 12:21:44 +0200 Subject: [PATCH] [fenix] Bug 1815424 - Show Dialog should not be called multiple times. --- .../fenix/browser/BaseBrowserFragment.kt | 47 +++++++++++-------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt b/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt index c7a62ca30d..b119935c0b 100644 --- a/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt @@ -520,28 +520,37 @@ abstract class BaseBrowserFragment : requestPermissions(permissions, REQUEST_CODE_DOWNLOAD_PERMISSIONS) }, customFirstPartyDownloadDialog = { filename, contentSize, positiveAction, negativeAction -> - FirstPartyDownloadDialog( - activity = requireActivity(), - filename = filename.value, - contentSize = contentSize.value, - positiveButtonAction = positiveAction.value, - negativeButtonAction = negativeAction.value, - ).onDismiss { - currentStartDownloadDialog = null - }.show(binding.startDownloadDialogContainer).also { - currentStartDownloadDialog = it + run { + if (currentStartDownloadDialog == null) { + FirstPartyDownloadDialog( + activity = requireActivity(), + filename = filename.value, + contentSize = contentSize.value, + positiveButtonAction = positiveAction.value, + negativeButtonAction = negativeAction.value, + ).onDismiss { + currentStartDownloadDialog = null + }.show(binding.startDownloadDialogContainer) + .also { + currentStartDownloadDialog = it + } + } } }, customThirdPartyDownloadDialog = { downloaderApps, onAppSelected, negativeActionCallback -> - ThirdPartyDownloadDialog( - activity = requireActivity(), - downloaderApps = downloaderApps.value, - onAppSelected = onAppSelected.value, - negativeButtonAction = negativeActionCallback.value, - ).onDismiss { - currentStartDownloadDialog = null - }.show(binding.startDownloadDialogContainer).also { - currentStartDownloadDialog = it + run { + if (currentStartDownloadDialog == null) { + ThirdPartyDownloadDialog( + activity = requireActivity(), + downloaderApps = downloaderApps.value, + onAppSelected = onAppSelected.value, + negativeButtonAction = negativeActionCallback.value, + ).onDismiss { + currentStartDownloadDialog = null + }.show(binding.startDownloadDialogContainer).also { + currentStartDownloadDialog = it + } + } } }, )