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 17:36:18 +06:00
co-authored by Quickdev
parent 157679bba5
commit 0c1be369b0
4 changed files with 18 additions and 4 deletions
@@ -12,6 +12,7 @@ enum class DownloadAction {
enum class EditCoverAction {
EDIT,
DELETE,
ADD_TO_LIBRARY,
}
enum class MangaScreenItem {
@@ -65,6 +65,7 @@ import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.material.Scaffold
import tachiyomi.presentation.core.i18n.stringResource
import tachiyomi.presentation.core.util.clickableNoIndication
import tachiyomi.source.local.isLocal
@Composable
fun MangaCoverDialog(
@@ -125,10 +126,12 @@ fun MangaCoverDialog(
var expanded by remember { mutableStateOf(false) }
IconButton(
onClick = {
if (isCustomCover) {
expanded = true
} else {
onEditClick(EditCoverAction.EDIT)
when {
!manga.favorite && !manga.isLocal() -> {
onEditClick(EditCoverAction.ADD_TO_LIBRARY)
}
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) {
viewModelScope.launch {
snackbarHostState.showSnackbar(
@@ -253,6 +253,7 @@ class MangaScreen(
when (it) {
EditCoverAction.EDIT -> getContent.launch("image/*")
EditCoverAction.DELETE -> vm.deleteCustomCover(context)
EditCoverAction.ADD_TO_LIBRARY -> vm.addToLibraryWarning(context)
}
},
onDismissRequest = onDismissRequest,