Ask to add an entry to the library before editing its cover (#2265)

Closes #2265

Co-authored-by: Quickdev <fyfrive@gmail.com>
This commit is contained in:
AntsyLich
2026-10-10 01:56:34 +06:00
parent 157679bba5
commit 0c1be369b0
4 changed files with 18 additions and 4 deletions
@@ -12,6 +12,7 @@ enum class DownloadAction {
enum class EditCoverAction { enum class EditCoverAction {
EDIT, EDIT,
DELETE, DELETE,
ADD_TO_LIBRARY,
} }
enum class MangaScreenItem { enum class MangaScreenItem {
@@ -65,6 +65,7 @@ import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.material.Scaffold import tachiyomi.presentation.core.components.material.Scaffold
import tachiyomi.presentation.core.i18n.stringResource import tachiyomi.presentation.core.i18n.stringResource
import tachiyomi.presentation.core.util.clickableNoIndication import tachiyomi.presentation.core.util.clickableNoIndication
import tachiyomi.source.local.isLocal
@Composable @Composable
fun MangaCoverDialog( fun MangaCoverDialog(
@@ -125,10 +126,12 @@ fun MangaCoverDialog(
var expanded by remember { mutableStateOf(false) } var expanded by remember { mutableStateOf(false) }
IconButton( IconButton(
onClick = { onClick = {
if (isCustomCover) { when {
expanded = true !manga.favorite && !manga.isLocal() -> {
} else { onEditClick(EditCoverAction.ADD_TO_LIBRARY)
onEditClick(EditCoverAction.EDIT) }
isCustomCover -> expanded = true
else -> onEditClick(EditCoverAction.EDIT)
} }
}, },
) { ) {
@@ -160,6 +160,15 @@ class MangaCoverViewModel(
} }
} }
fun addToLibraryWarning(context: Context) {
viewModelScope.launch {
snackbarHostState.showSnackbar(
context.stringResource(MR.strings.notification_first_add_to_library),
withDismissAction = true,
)
}
}
private fun notifyCoverUpdated(context: Context) { private fun notifyCoverUpdated(context: Context) {
viewModelScope.launch { viewModelScope.launch {
snackbarHostState.showSnackbar( snackbarHostState.showSnackbar(
@@ -253,6 +253,7 @@ class MangaScreen(
when (it) { when (it) {
EditCoverAction.EDIT -> getContent.launch("image/*") EditCoverAction.EDIT -> getContent.launch("image/*")
EditCoverAction.DELETE -> vm.deleteCustomCover(context) EditCoverAction.DELETE -> vm.deleteCustomCover(context)
EditCoverAction.ADD_TO_LIBRARY -> vm.addToLibraryWarning(context)
} }
}, },
onDismissRequest = onDismissRequest, onDismissRequest = onDismissRequest,