Add ability to reset chapter flags to defaults
Closes #10063 (cherry picked from commit 118d3b7fcc5cf8a27e52ff690cb3ecd28860c10c) # Conflicts: # app/src/main/java/eu/kanade/presentation/manga/ChapterSettingsDialog.kt # app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt # app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreen.kt # data/src/main/sqldelight/tachiyomi/data/mangas.sq
This commit is contained in:
parent
47f9bf08cc
commit
80a07631bf
@ -9,7 +9,7 @@ class SetMangaViewerFlags(
|
|||||||
private val mangaRepository: MangaRepository,
|
private val mangaRepository: MangaRepository,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
suspend fun awaitSetMangaReadingMode(id: Long, flag: Long) {
|
suspend fun awaitSetReadingMode(id: Long, flag: Long) {
|
||||||
val manga = mangaRepository.getMangaById(id)
|
val manga = mangaRepository.getMangaById(id)
|
||||||
mangaRepository.update(
|
mangaRepository.update(
|
||||||
MangaUpdate(
|
MangaUpdate(
|
||||||
@ -19,7 +19,7 @@ class SetMangaViewerFlags(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun awaitSetOrientationType(id: Long, flag: Long) {
|
suspend fun awaitSetOrientation(id: Long, flag: Long) {
|
||||||
val manga = mangaRepository.getMangaById(id)
|
val manga = mangaRepository.getMangaById(id)
|
||||||
mangaRepository.update(
|
mangaRepository.update(
|
||||||
MangaUpdate(
|
MangaUpdate(
|
||||||
|
@ -48,7 +48,10 @@ fun ChapterSettingsDialog(
|
|||||||
onSortModeChanged: (Long) -> Unit,
|
onSortModeChanged: (Long) -> Unit,
|
||||||
onDisplayModeChanged: (Long) -> Unit,
|
onDisplayModeChanged: (Long) -> Unit,
|
||||||
onSetAsDefault: (applyToExistingManga: Boolean) -> Unit,
|
onSetAsDefault: (applyToExistingManga: Boolean) -> Unit,
|
||||||
|
onResetToDefault: () -> Unit,
|
||||||
|
// SY -->
|
||||||
onClickShowScanlatorSelection: (() -> Unit)?,
|
onClickShowScanlatorSelection: (() -> Unit)?,
|
||||||
|
// SY <--
|
||||||
) {
|
) {
|
||||||
var showSetAsDefaultDialog by rememberSaveable { mutableStateOf(false) }
|
var showSetAsDefaultDialog by rememberSaveable { mutableStateOf(false) }
|
||||||
if (showSetAsDefaultDialog) {
|
if (showSetAsDefaultDialog) {
|
||||||
@ -73,6 +76,13 @@ fun ChapterSettingsDialog(
|
|||||||
closeMenu()
|
closeMenu()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = { Text(stringResource(R.string.action_reset)) },
|
||||||
|
onClick = {
|
||||||
|
onResetToDefault()
|
||||||
|
closeMenu()
|
||||||
|
},
|
||||||
|
)
|
||||||
},
|
},
|
||||||
) { page ->
|
) { page ->
|
||||||
Column(
|
Column(
|
||||||
|
@ -79,6 +79,7 @@ import tachiyomi.core.util.system.logcat
|
|||||||
import tachiyomi.domain.UnsortedPreferences
|
import tachiyomi.domain.UnsortedPreferences
|
||||||
import tachiyomi.domain.chapter.interactor.GetChapterByMangaId
|
import tachiyomi.domain.chapter.interactor.GetChapterByMangaId
|
||||||
import tachiyomi.domain.manga.interactor.GetAllManga
|
import tachiyomi.domain.manga.interactor.GetAllManga
|
||||||
|
import tachiyomi.domain.manga.interactor.ResetViewerFlags
|
||||||
import tachiyomi.domain.manga.repository.MangaRepository
|
import tachiyomi.domain.manga.repository.MangaRepository
|
||||||
import tachiyomi.domain.source.service.SourceManager
|
import tachiyomi.domain.source.service.SourceManager
|
||||||
import tachiyomi.presentation.core.components.LabeledCheckbox
|
import tachiyomi.presentation.core.components.LabeledCheckbox
|
||||||
@ -336,7 +337,7 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||||||
subtitle = stringResource(R.string.pref_reset_viewer_flags_summary),
|
subtitle = stringResource(R.string.pref_reset_viewer_flags_summary),
|
||||||
onClick = {
|
onClick = {
|
||||||
scope.launchNonCancellable {
|
scope.launchNonCancellable {
|
||||||
val success = Injekt.get<MangaRepository>().resetViewerFlags()
|
val success = Injekt.get<ResetViewerFlags>().await()
|
||||||
withUIContext {
|
withUIContext {
|
||||||
val message = if (success) {
|
val message = if (success) {
|
||||||
R.string.pref_reset_viewer_flags_success
|
R.string.pref_reset_viewer_flags_success
|
||||||
|
@ -233,6 +233,7 @@ class MangaScreen(
|
|||||||
onSortModeChanged = screenModel::setSorting,
|
onSortModeChanged = screenModel::setSorting,
|
||||||
onDisplayModeChanged = screenModel::setDisplayMode,
|
onDisplayModeChanged = screenModel::setDisplayMode,
|
||||||
onSetAsDefault = screenModel::setCurrentSettingsAsDefault,
|
onSetAsDefault = screenModel::setCurrentSettingsAsDefault,
|
||||||
|
onResetToDefault = screenModel::resetToDefaultSettings,
|
||||||
// SY -->
|
// SY -->
|
||||||
onClickShowScanlatorSelection = { showScanlatorsDialog = true }.takeIf { successState.scanlators.size > 1 },
|
onClickShowScanlatorSelection = { showScanlatorsDialog = true }.takeIf { successState.scanlators.size > 1 },
|
||||||
// SY <--
|
// SY <--
|
||||||
|
@ -1336,6 +1336,13 @@ class MangaScreenModel(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun resetToDefaultSettings() {
|
||||||
|
val manga = successState?.manga ?: return
|
||||||
|
screenModelScope.launchNonCancellable {
|
||||||
|
setMangaDefaultChapterFlags.await(manga)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun toggleSelection(
|
fun toggleSelection(
|
||||||
item: ChapterItem,
|
item: ChapterItem,
|
||||||
selected: Boolean,
|
selected: Boolean,
|
||||||
|
@ -806,7 +806,7 @@ class ReaderViewModel @JvmOverloads constructor(
|
|||||||
fun setMangaReadingMode(readingModeType: ReadingModeType) {
|
fun setMangaReadingMode(readingModeType: ReadingModeType) {
|
||||||
val manga = manga ?: return
|
val manga = manga ?: return
|
||||||
runBlocking(Dispatchers.IO) {
|
runBlocking(Dispatchers.IO) {
|
||||||
setMangaViewerFlags.awaitSetMangaReadingMode(manga.id, readingModeType.flagValue.toLong())
|
setMangaViewerFlags.awaitSetReadingMode(manga.id, readingModeType.flagValue.toLong())
|
||||||
val currChapters = state.value.viewerChapters
|
val currChapters = state.value.viewerChapters
|
||||||
if (currChapters != null) {
|
if (currChapters != null) {
|
||||||
// Save current page
|
// Save current page
|
||||||
@ -842,7 +842,7 @@ class ReaderViewModel @JvmOverloads constructor(
|
|||||||
fun setMangaOrientationType(rotationType: OrientationType) {
|
fun setMangaOrientationType(rotationType: OrientationType) {
|
||||||
val manga = manga ?: return
|
val manga = manga ?: return
|
||||||
viewModelScope.launchIO {
|
viewModelScope.launchIO {
|
||||||
setMangaViewerFlags.awaitSetOrientationType(manga.id, rotationType.flagValue.toLong())
|
setMangaViewerFlags.awaitSetOrientation(manga.id, rotationType.flagValue.toLong())
|
||||||
val currChapters = state.value.viewerChapters
|
val currChapters = state.value.viewerChapters
|
||||||
if (currChapters != null) {
|
if (currChapters != null) {
|
||||||
// Save current page
|
// Save current page
|
||||||
|
@ -58,7 +58,8 @@ WHERE _id = :id;
|
|||||||
getMangaByUrlAndSource:
|
getMangaByUrlAndSource:
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM mangas
|
FROM mangas
|
||||||
WHERE url = :url AND source = :source
|
WHERE url = :url
|
||||||
|
AND source = :source
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
getFavorites:
|
getFavorites:
|
||||||
@ -115,7 +116,9 @@ GROUP BY source;
|
|||||||
|
|
||||||
deleteMangasNotInLibraryBySourceIds:
|
deleteMangasNotInLibraryBySourceIds:
|
||||||
DELETE FROM mangas
|
DELETE FROM mangas
|
||||||
WHERE favorite = 0 AND source IN :sourceIdsAND AND _id NOT IN (
|
WHERE favorite = 0
|
||||||
|
AND source IN :sourceIds
|
||||||
|
AND _id NOT IN (
|
||||||
SELECT manga_id FROM merged WHERE manga_id != merge_id
|
SELECT manga_id FROM merged WHERE manga_id != merge_id
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -128,8 +131,8 @@ WHERE favorite = 0 AND source IN :sourceIdsAND AND _id NOT IN (
|
|||||||
);
|
);
|
||||||
|
|
||||||
insert:
|
insert:
|
||||||
INSERT INTO mangas(source,url,artist,author,description,genre,title,status,thumbnail_url,favorite,last_update,next_update,initialized,viewer,chapter_flags,cover_last_modified,date_added,filtered_scanlators,update_strategy,calculate_interval, last_modified_at)
|
INSERT INTO mangas(source, url, artist, author, description, genre, title, status, thumbnail_url, favorite, last_update, next_update, initialized, viewer, chapter_flags, cover_last_modified, date_added, filtered_scanlators, update_strategy, calculate_interval, last_modified_at)
|
||||||
VALUES (:source,:url,:artist,:author,:description,:genre,:title,:status,:thumbnailUrl,:favorite,:lastUpdate,:nextUpdate,:initialized,:viewerFlags,:chapterFlags,:coverLastModified,:dateAdded,:filteredScanlators,:updateStrategy,:calculateInterval, strftime('%s', 'now'));
|
VALUES (:source, :url, :artist, :author, :description, :genre, :title, :status, :thumbnailUrl, :favorite, :lastUpdate, :nextUpdate, :initialized, :viewerFlags, :chapterFlags, :coverLastModified, :dateAdded, :filteredScanlators, :updateStrategy, :calculateInterval, strftime('%s', 'now'));
|
||||||
|
|
||||||
update:
|
update:
|
||||||
UPDATE mangas SET
|
UPDATE mangas SET
|
||||||
|
Loading…
x
Reference in New Issue
Block a user