diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryDetailContent.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryDetailContent.kt index f1bf39810..3fe535122 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryDetailContent.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryDetailContent.kt @@ -1,6 +1,5 @@ package com.hippo.ehviewer.ui.screen -import android.Manifest import android.content.ActivityNotFoundException import android.content.Context import android.content.Intent @@ -131,10 +130,7 @@ import com.hippo.ehviewer.ui.tools.rememberInVM import com.hippo.ehviewer.util.FavouriteStatusRouter import com.hippo.ehviewer.util.addTextToClipboard import com.hippo.ehviewer.util.bgWork -import com.hippo.ehviewer.util.displayString import com.hippo.ehviewer.util.flattenForEach -import com.hippo.ehviewer.util.isAtLeastQ -import com.hippo.ehviewer.util.requestPermission import com.ramcosta.composedestinations.navigation.DestinationsNavigator import eu.kanade.tachiyomi.util.lang.launchIO import eu.kanade.tachiyomi.util.lang.launchUI @@ -150,6 +146,7 @@ import kotlinx.coroutines.Job import kotlinx.coroutines.async import kotlinx.coroutines.launch import moe.tarsin.coroutines.runSuspendCatching +import moe.tarsin.coroutines.runSwallowingWithUI context(CoroutineScope, DestinationsNavigator, DialogState, MainActivity, SnackbarHostState, SharedTransitionScope, TransitionsVisibilityScope) @Composable @@ -581,19 +578,9 @@ fun BelowHeader(galleryDetail: GalleryDetail) { text = torrentText, onClick = { launchIO { - if (galleryDetail.torrentCount > 0) { - val granted = isAtLeastQ || requestPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) - if (granted) { - runSuspendCatching { - showTorrentDialog() - }.onFailure { - showSnackbar(it.displayString()) - } - } else { - showSnackbar(permissionDenied) - } - } else { - showSnackbar(noTorrents) + when { + galleryDetail.torrentCount <= 0 -> showSnackbar(noTorrents) + else -> runSwallowingWithUI { showTorrentDialog() } } } },