|
@@ -83,7 +83,11 @@ class MangaReaderViewModel(
|
|
|
viewModelScope.launch {
|
|
viewModelScope.launch {
|
|
|
mangaSettingsGateway.settings.collect { settings ->
|
|
mangaSettingsGateway.settings.collect { settings ->
|
|
|
latestMangaSettings = settings
|
|
latestMangaSettings = settings
|
|
|
- readerSession.execute(MangaSessionCommand.PrefetchCountChanged(settings.chapterPrefetchCount))
|
|
|
|
|
|
|
+ readerSession.execute(
|
|
|
|
|
+ MangaSessionCommand.PrefetchCountChanged(
|
|
|
|
|
+ if (settings.autoOfflineCache) settings.chapterPrefetchCount else 0,
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
_uiState.update { state ->
|
|
_uiState.update { state ->
|
|
|
state.copy(settings = readSettings(settings))
|
|
state.copy(settings = readSettings(settings))
|
|
|
}
|
|
}
|
|
@@ -262,6 +266,7 @@ class MangaReaderViewModel(
|
|
|
intent.itemIndex,
|
|
intent.itemIndex,
|
|
|
intent.firstItemIndex,
|
|
intent.firstItemIndex,
|
|
|
intent.lastItemIndex,
|
|
intent.lastItemIndex,
|
|
|
|
|
+ intent.currentChapterVisible,
|
|
|
intent.navigationId,
|
|
intent.navigationId,
|
|
|
)
|
|
)
|
|
|
is MangaReaderIntent.PagerScrollChanged -> {
|
|
is MangaReaderIntent.PagerScrollChanged -> {
|
|
@@ -599,6 +604,7 @@ class MangaReaderViewModel(
|
|
|
itemIndex = targetIndex,
|
|
itemIndex = targetIndex,
|
|
|
firstItemIndex = targetIndex,
|
|
firstItemIndex = targetIndex,
|
|
|
lastItemIndex = targetIndex,
|
|
lastItemIndex = targetIndex,
|
|
|
|
|
+ currentChapterVisible = true,
|
|
|
navigationId = _uiState.value.navigationId,
|
|
navigationId = _uiState.value.navigationId,
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
@@ -781,6 +787,9 @@ class MangaReaderViewModel(
|
|
|
MangaReaderSettingKey.CHAPTER_PREFETCH -> updateMangaPreference {
|
|
MangaReaderSettingKey.CHAPTER_PREFETCH -> updateMangaPreference {
|
|
|
it.copy(chapterPrefetchCount = value)
|
|
it.copy(chapterPrefetchCount = value)
|
|
|
}
|
|
}
|
|
|
|
|
+ MangaReaderSettingKey.AUTO_OFFLINE_CACHE -> updateMangaPreference {
|
|
|
|
|
+ it.copy(autoOfflineCache = enabled)
|
|
|
|
|
+ }
|
|
|
MangaReaderSettingKey.AUTO_READ_SPEED -> updateMangaPreference { it.copy(autoPageSpeed = value) }
|
|
MangaReaderSettingKey.AUTO_READ_SPEED -> updateMangaPreference { it.copy(autoPageSpeed = value) }
|
|
|
MangaReaderSettingKey.VOLUME_KEY_PAGE -> updateMangaPreference { it.copy(volumeKeyPage = enabled) }
|
|
MangaReaderSettingKey.VOLUME_KEY_PAGE -> updateMangaPreference { it.copy(volumeKeyPage = enabled) }
|
|
|
MangaReaderSettingKey.REVERSE_VOLUME_KEY_PAGE -> updateMangaPreference {
|
|
MangaReaderSettingKey.REVERSE_VOLUME_KEY_PAGE -> updateMangaPreference {
|
|
@@ -1090,6 +1099,7 @@ class MangaReaderViewModel(
|
|
|
itemIndex: Int,
|
|
itemIndex: Int,
|
|
|
firstItemIndex: Int,
|
|
firstItemIndex: Int,
|
|
|
lastItemIndex: Int,
|
|
lastItemIndex: Int,
|
|
|
|
|
+ currentChapterVisible: Boolean,
|
|
|
navigationId: Long,
|
|
navigationId: Long,
|
|
|
) {
|
|
) {
|
|
|
val state = _uiState.value
|
|
val state = _uiState.value
|
|
@@ -1117,6 +1127,7 @@ class MangaReaderViewModel(
|
|
|
when (mangaChapterSwitchDecision(
|
|
when (mangaChapterSwitchDecision(
|
|
|
currentChapterIndex = readerSession.state.value.chapterIndex,
|
|
currentChapterIndex = readerSession.state.value.chapterIndex,
|
|
|
visibleChapterIndex = item.chapterIndex,
|
|
visibleChapterIndex = item.chapterIndex,
|
|
|
|
|
+ currentChapterVisible = currentChapterVisible,
|
|
|
)) {
|
|
)) {
|
|
|
MangaChapterSwitch.NEXT,
|
|
MangaChapterSwitch.NEXT,
|
|
|
MangaChapterSwitch.PREVIOUS -> executeSession(
|
|
MangaChapterSwitch.PREVIOUS -> executeSession(
|
|
@@ -1218,10 +1229,11 @@ class MangaReaderViewModel(
|
|
|
disableScrollAnimation = settings.disableMangaScrollAnimation,
|
|
disableScrollAnimation = settings.disableMangaScrollAnimation,
|
|
|
disableCrossFade = settings.disableMangaCrossFade,
|
|
disableCrossFade = settings.disableMangaCrossFade,
|
|
|
disableClickScroll = settings.disableClickScroll,
|
|
disableClickScroll = settings.disableClickScroll,
|
|
|
- longPressEnabled = settings.longClick,
|
|
|
|
|
- preDownloadCount = settings.preDownloadNum,
|
|
|
|
|
|
|
+ longPressEnabled = settings.longClick,
|
|
|
|
|
+ preDownloadCount = settings.preDownloadNum,
|
|
|
chapterPrefetchCount = settings.chapterPrefetchCount,
|
|
chapterPrefetchCount = settings.chapterPrefetchCount,
|
|
|
- autoReadSpeed = settings.autoPageSpeed,
|
|
|
|
|
|
|
+ autoOfflineCache = settings.autoOfflineCache,
|
|
|
|
|
+ autoReadSpeed = settings.autoPageSpeed,
|
|
|
volumeKeyPage = settings.volumeKeyPage,
|
|
volumeKeyPage = settings.volumeKeyPage,
|
|
|
reverseVolumeKeyPage = settings.reverseVolumeKeyPage,
|
|
reverseVolumeKeyPage = settings.reverseVolumeKeyPage,
|
|
|
hideMangaTitle = settings.hideTitle,
|
|
hideMangaTitle = settings.hideTitle,
|