mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-10 06:42:05 +01:00
Lint fixes
This commit is contained in:
@@ -72,7 +72,7 @@ subprojects {
|
|||||||
"ca/gosyer/jui/*/build",
|
"ca/gosyer/jui/*/build",
|
||||||
"**/generated/**",
|
"**/generated/**",
|
||||||
"ca/gosyer/jui/data/graphql",
|
"ca/gosyer/jui/data/graphql",
|
||||||
"ca/gosyer/jui/uicore/icons/juiassets",
|
"ca/gosyer/jui/desktop/InjectAppComponent.kt"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
plugins.withType<com.android.build.gradle.BasePlugin> {
|
plugins.withType<com.android.build.gradle.BasePlugin> {
|
||||||
|
|||||||
@@ -46,10 +46,6 @@ class SavedStateHandleStateFlow<T>(
|
|||||||
) : StateFlow<T> by stateFlow {
|
) : StateFlow<T> by stateFlow {
|
||||||
override var value: T
|
override var value: T
|
||||||
get() = stateFlow.value
|
get() = stateFlow.value
|
||||||
|
|
||||||
/**
|
|
||||||
* May have to be called on the main thread if there is a livedata with the same [key]
|
|
||||||
*/
|
|
||||||
set(value) = savedStateHandle.set(key, value)
|
set(value) = savedStateHandle.set(key, value)
|
||||||
|
|
||||||
fun asStateFlow() = stateFlow
|
fun asStateFlow() = stateFlow
|
||||||
|
|||||||
@@ -83,8 +83,8 @@ class MangaScreenViewModel(
|
|||||||
private val _chapters = MutableStateFlow<ImmutableList<ChapterDownloadItem>>(persistentListOf())
|
private val _chapters = MutableStateFlow<ImmutableList<ChapterDownloadItem>>(persistentListOf())
|
||||||
val chapters = _chapters.asStateFlow()
|
val chapters = _chapters.asStateFlow()
|
||||||
|
|
||||||
private val _selectedIds = MutableStateFlow<ImmutableList<Long>>(persistentListOf())
|
private val selectedIds = MutableStateFlow<ImmutableList<Long>>(persistentListOf())
|
||||||
val selectedItems = combine(chapters, _selectedIds) { chapters, selecteditems ->
|
val selectedItems = combine(chapters, selectedIds) { chapters, selecteditems ->
|
||||||
chapters.filter { it.isSelected(selecteditems) }.toImmutableList()
|
chapters.filter { it.isSelected(selecteditems) }.toImmutableList()
|
||||||
}.stateIn(scope, SharingStarted.Eagerly, persistentListOf())
|
}.stateIn(scope, SharingStarted.Eagerly, persistentListOf())
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ class MangaScreenViewModel(
|
|||||||
val categoriesExist = categories.map { it.isNotEmpty() }
|
val categoriesExist = categories.map { it.isNotEmpty() }
|
||||||
.stateIn(scope, SharingStarted.Eagerly, true)
|
.stateIn(scope, SharingStarted.Eagerly, true)
|
||||||
|
|
||||||
val inActionMode = _selectedIds.map { it.isNotEmpty() }
|
val inActionMode = selectedIds.map { it.isNotEmpty() }
|
||||||
.stateIn(scope, SharingStarted.Eagerly, false)
|
.stateIn(scope, SharingStarted.Eagerly, false)
|
||||||
|
|
||||||
private val chooseCategoriesFlow = MutableSharedFlow<Unit>()
|
private val chooseCategoriesFlow = MutableSharedFlow<Unit>()
|
||||||
@@ -292,15 +292,15 @@ class MangaScreenViewModel(
|
|||||||
scope.launch {
|
scope.launch {
|
||||||
manga.value?.let {
|
manga.value?.let {
|
||||||
updateChapter.await(chapterIds, read = read, onError = { toast(it.message.orEmpty()) })
|
updateChapter.await(chapterIds, read = read, onError = { toast(it.message.orEmpty()) })
|
||||||
_selectedIds.value = persistentListOf()
|
selectedIds.value = persistentListOf()
|
||||||
loadChapters()
|
loadChapters()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun markRead(id: Long?) = setRead(listOfNotNull(id).ifEmpty { _selectedIds.value }, true)
|
fun markRead(id: Long?) = setRead(listOfNotNull(id).ifEmpty { selectedIds.value }, true)
|
||||||
|
|
||||||
fun markUnread(id: Long?) = setRead(listOfNotNull(id).ifEmpty { _selectedIds.value }, false)
|
fun markUnread(id: Long?) = setRead(listOfNotNull(id).ifEmpty { selectedIds.value }, false)
|
||||||
|
|
||||||
private fun setBookmarked(
|
private fun setBookmarked(
|
||||||
chapterIds: List<Long>,
|
chapterIds: List<Long>,
|
||||||
@@ -309,15 +309,15 @@ class MangaScreenViewModel(
|
|||||||
scope.launch {
|
scope.launch {
|
||||||
manga.value?.let {
|
manga.value?.let {
|
||||||
updateChapter.await(chapterIds, bookmarked = bookmark, onError = { toast(it.message.orEmpty()) })
|
updateChapter.await(chapterIds, bookmarked = bookmark, onError = { toast(it.message.orEmpty()) })
|
||||||
_selectedIds.value = persistentListOf()
|
selectedIds.value = persistentListOf()
|
||||||
loadChapters()
|
loadChapters()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bookmarkChapter(id: Long?) = setBookmarked(listOfNotNull(id).ifEmpty { _selectedIds.value }, true)
|
fun bookmarkChapter(id: Long?) = setBookmarked(listOfNotNull(id).ifEmpty { selectedIds.value }, true)
|
||||||
|
|
||||||
fun unBookmarkChapter(id: Long?) = setBookmarked(listOfNotNull(id).ifEmpty { _selectedIds.value }, false)
|
fun unBookmarkChapter(id: Long?) = setBookmarked(listOfNotNull(id).ifEmpty { selectedIds.value }, false)
|
||||||
|
|
||||||
fun markPreviousRead(index: Int) {
|
fun markPreviousRead(index: Int) {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
@@ -326,7 +326,7 @@ class MangaScreenViewModel(
|
|||||||
.sortedBy { it.chapter.index }
|
.sortedBy { it.chapter.index }
|
||||||
.subList(0, index).map { it.chapter.id } // todo test
|
.subList(0, index).map { it.chapter.id } // todo test
|
||||||
updateChapter.await(chapters, read = true, onError = { toast(it.message.orEmpty()) })
|
updateChapter.await(chapters, read = true, onError = { toast(it.message.orEmpty()) })
|
||||||
_selectedIds.value = persistentListOf()
|
selectedIds.value = persistentListOf()
|
||||||
loadChapters()
|
loadChapters()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -339,12 +339,12 @@ class MangaScreenViewModel(
|
|||||||
fun deleteDownload(id: Long?) {
|
fun deleteDownload(id: Long?) {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
val chapterIds = _selectedIds.value
|
val chapterIds = selectedIds.value
|
||||||
deleteChapterDownload.await(chapterIds, onError = { toast(it.message.orEmpty()) })
|
deleteChapterDownload.await(chapterIds, onError = { toast(it.message.orEmpty()) })
|
||||||
selectedItems.value.forEach {
|
selectedItems.value.forEach {
|
||||||
it.setNotDownloaded()
|
it.setNotDownloaded()
|
||||||
}
|
}
|
||||||
_selectedIds.value = persistentListOf()
|
selectedIds.value = persistentListOf()
|
||||||
} else {
|
} else {
|
||||||
chapters.value.find { it.chapter.id == id }
|
chapters.value.find { it.chapter.id == id }
|
||||||
?.deleteDownload(deleteChapterDownload)
|
?.deleteDownload(deleteChapterDownload)
|
||||||
@@ -361,38 +361,38 @@ class MangaScreenViewModel(
|
|||||||
|
|
||||||
fun selectAll() {
|
fun selectAll() {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
_selectedIds.value = chapters.value.map { it.chapter.id }.toImmutableList()
|
selectedIds.value = chapters.value.map { it.chapter.id }.toImmutableList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun invertSelection() {
|
fun invertSelection() {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
_selectedIds.value = chapters.value.map { it.chapter.id }.minus(_selectedIds.value).toImmutableList()
|
selectedIds.value = chapters.value.map { it.chapter.id }.minus(selectedIds.value).toImmutableList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun selectChapter(id: Long) {
|
fun selectChapter(id: Long) {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
_selectedIds.value = _selectedIds.value.plus(id).toImmutableList()
|
selectedIds.value = selectedIds.value.plus(id).toImmutableList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun unselectChapter(id: Long) {
|
fun unselectChapter(id: Long) {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
_selectedIds.value = _selectedIds.value.minus(id).toImmutableList()
|
selectedIds.value = selectedIds.value.minus(id).toImmutableList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clearSelection() {
|
fun clearSelection() {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
_selectedIds.value = persistentListOf()
|
selectedIds.value = persistentListOf()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun downloadChapters() {
|
fun downloadChapters() {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
batchChapterDownload.await(_selectedIds.value)
|
batchChapterDownload.await(selectedIds.value)
|
||||||
_selectedIds.value = persistentListOf()
|
selectedIds.value = persistentListOf()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class ReaderMenuViewModel(
|
|||||||
@Assisted private val params: Params,
|
@Assisted private val params: Params,
|
||||||
) : ViewModel(contextWrapper) {
|
) : ViewModel(contextWrapper) {
|
||||||
override val scope = MainScope()
|
override val scope = MainScope()
|
||||||
private val _manga = MutableStateFlow<Manga?>(null)
|
private val manga = MutableStateFlow<Manga?>(null)
|
||||||
private val viewerChapters = MutableStateFlow(ViewerChapters(null, null, null))
|
private val viewerChapters = MutableStateFlow(ViewerChapters(null, null, null))
|
||||||
val previousChapter = viewerChapters.map { it.prevChapter }.stateIn(scope, SharingStarted.Eagerly, null)
|
val previousChapter = viewerChapters.map { it.prevChapter }.stateIn(scope, SharingStarted.Eagerly, null)
|
||||||
val chapter = viewerChapters.map { it.currChapter }.stateIn(scope, SharingStarted.Eagerly, null)
|
val chapter = viewerChapters.map { it.currChapter }.stateIn(scope, SharingStarted.Eagerly, null)
|
||||||
@@ -133,7 +133,7 @@ class ReaderMenuViewModel(
|
|||||||
.getAsFlow()
|
.getAsFlow()
|
||||||
.map { it.toImmutableList() }
|
.map { it.toImmutableList() }
|
||||||
.stateIn(scope, SharingStarted.Eagerly, persistentListOf())
|
.stateIn(scope, SharingStarted.Eagerly, persistentListOf())
|
||||||
val readerMode = combine(readerPreferences.mode().getAsFlow(), _manga) { mode, manga ->
|
val readerMode = combine(readerPreferences.mode().getAsFlow(), manga) { mode, manga ->
|
||||||
val mangaMode = manga?.meta?.juiReaderMode?.decodeURLQueryComponent()
|
val mangaMode = manga?.meta?.juiReaderMode?.decodeURLQueryComponent()
|
||||||
if (
|
if (
|
||||||
mangaMode != null &&
|
mangaMode != null &&
|
||||||
@@ -258,7 +258,7 @@ class ReaderMenuViewModel(
|
|||||||
|
|
||||||
fun setMangaReaderMode(mode: String) {
|
fun setMangaReaderMode(mode: String) {
|
||||||
scope.launchDefault {
|
scope.launchDefault {
|
||||||
_manga.value?.let {
|
manga.value?.let {
|
||||||
updateMangaMeta.await(it, mode, onError = { toast(it.message.orEmpty()) })
|
updateMangaMeta.await(it, mode, onError = { toast(it.message.orEmpty()) })
|
||||||
}
|
}
|
||||||
initManga(params.mangaId)
|
initManga(params.mangaId)
|
||||||
@@ -301,7 +301,7 @@ class ReaderMenuViewModel(
|
|||||||
getManga.asFlow(mangaId)
|
getManga.asFlow(mangaId)
|
||||||
.take(1)
|
.take(1)
|
||||||
.onEach {
|
.onEach {
|
||||||
_manga.value = it
|
manga.value = it
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
_state.value = ReaderChapter.State.Error(it)
|
_state.value = ReaderChapter.State.Error(it)
|
||||||
|
|||||||
@@ -107,8 +107,8 @@ class SettingsBackupScreen : Screen {
|
|||||||
SettingsBackupScreenContent(
|
SettingsBackupScreenContent(
|
||||||
restoreStatus = vm.restoreStatus.collectAsState().value,
|
restoreStatus = vm.restoreStatus.collectAsState().value,
|
||||||
creatingStatus = vm.creatingStatus.collectAsState().value,
|
creatingStatus = vm.creatingStatus.collectAsState().value,
|
||||||
missingSourceFlowHolder = vm.missingSourceFlowHolder,
|
missingSourceFlowHolder = vm.missingSourceFlow,
|
||||||
createFlowHolder = vm.createFlowHolder,
|
createFlowHolder = vm.createFlow,
|
||||||
restoreFile = vm::restoreFile,
|
restoreFile = vm::restoreFile,
|
||||||
restoreBackup = vm::restoreBackup,
|
restoreBackup = vm::restoreBackup,
|
||||||
stopRestore = vm::stopRestore,
|
stopRestore = vm::stopRestore,
|
||||||
@@ -129,12 +129,12 @@ class SettingsBackupViewModel(
|
|||||||
val restoreStatus = _restoreStatus.asStateFlow()
|
val restoreStatus = _restoreStatus.asStateFlow()
|
||||||
|
|
||||||
private val _missingSourceFlow = MutableSharedFlow<Pair<Path, ImmutableList<String>>>()
|
private val _missingSourceFlow = MutableSharedFlow<Pair<Path, ImmutableList<String>>>()
|
||||||
val missingSourceFlowHolder = StableHolder(_missingSourceFlow.asSharedFlow())
|
val missingSourceFlow = StableHolder(_missingSourceFlow.asSharedFlow())
|
||||||
|
|
||||||
private val _creatingStatus = MutableStateFlow<Status>(Status.Nothing)
|
private val _creatingStatus = MutableStateFlow<Status>(Status.Nothing)
|
||||||
val creatingStatus = _creatingStatus.asStateFlow()
|
val creatingStatus = _creatingStatus.asStateFlow()
|
||||||
private val _createFlow = MutableSharedFlow<String>()
|
private val _createFlow = MutableSharedFlow<String>()
|
||||||
val createFlowHolder = StableHolder(_createFlow.asSharedFlow())
|
val createFlow = StableHolder(_createFlow.asSharedFlow())
|
||||||
|
|
||||||
fun restoreFile(source: Source) {
|
fun restoreFile(source: Source) {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
|
|||||||
@@ -76,13 +76,13 @@ class SourceScreenViewModel(
|
|||||||
private val _isLatest by savedStateHandle.getStateFlow { false }
|
private val _isLatest by savedStateHandle.getStateFlow { false }
|
||||||
val isLatest = _isLatest.asStateFlow()
|
val isLatest = _isLatest.asStateFlow()
|
||||||
|
|
||||||
private val _usingFilters by savedStateHandle.getStateFlow { false }
|
private val usingFilters by savedStateHandle.getStateFlow { false }
|
||||||
private val filters = MutableStateFlow<List<SourceFilter>?>(null)
|
private val filters = MutableStateFlow<List<SourceFilter>?>(null)
|
||||||
|
|
||||||
private val _sourceSearchQuery by savedStateHandle.getStateFlow<String?> { initialQuery }
|
private val _sourceSearchQuery by savedStateHandle.getStateFlow { initialQuery }
|
||||||
val sourceSearchQuery = _sourceSearchQuery.asStateFlow()
|
val sourceSearchQuery = _sourceSearchQuery.asStateFlow()
|
||||||
|
|
||||||
private val _query = MutableStateFlow(sourceSearchQuery.value)
|
private val query = MutableStateFlow(sourceSearchQuery.value)
|
||||||
|
|
||||||
private val pager = MutableStateFlow(getPager())
|
private val pager = MutableStateFlow(getPager())
|
||||||
|
|
||||||
@@ -104,19 +104,19 @@ class SourceScreenViewModel(
|
|||||||
fun setMode(toLatest: Boolean) {
|
fun setMode(toLatest: Boolean) {
|
||||||
if (isLatest.value != toLatest) {
|
if (isLatest.value != toLatest) {
|
||||||
_isLatest.value = toLatest
|
_isLatest.value = toLatest
|
||||||
_query.value = null
|
query.value = null
|
||||||
updatePager()
|
updatePager()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getPager(): SourcePager {
|
private fun getPager(): SourcePager {
|
||||||
val fetcher: suspend (page: Int) -> MangaPage? = when {
|
val fetcher: suspend (page: Int) -> MangaPage? = when {
|
||||||
_query.value != null || _usingFilters.value -> {
|
query.value != null || usingFilters.value -> {
|
||||||
{ page ->
|
{ page ->
|
||||||
getSearchManga.await(
|
getSearchManga.await(
|
||||||
sourceId = source.id,
|
sourceId = source.id,
|
||||||
page = page,
|
page = page,
|
||||||
searchTerm = _query.value,
|
searchTerm = query.value,
|
||||||
filters = filters.value,
|
filters = filters.value,
|
||||||
onError = { toast(it.message.orEmpty()) },
|
onError = { toast(it.message.orEmpty()) },
|
||||||
)
|
)
|
||||||
@@ -154,12 +154,12 @@ class SourceScreenViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun startSearch(query: String?) {
|
fun startSearch(query: String?) {
|
||||||
_query.value = query
|
this.query.value = query
|
||||||
updatePager()
|
updatePager()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setUsingFilters(usingFilters: Boolean) {
|
fun setUsingFilters(usingFilters: Boolean) {
|
||||||
_usingFilters.value = usingFilters
|
this.usingFilters.value = usingFilters
|
||||||
}
|
}
|
||||||
|
|
||||||
fun search(query: String) {
|
fun search(query: String) {
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ class UpdatesScreenViewModel(
|
|||||||
}.toImmutableList()
|
}.toImmutableList()
|
||||||
}.stateIn(scope, SharingStarted.Eagerly, persistentListOf())
|
}.stateIn(scope, SharingStarted.Eagerly, persistentListOf())
|
||||||
|
|
||||||
private val _selectedIds = MutableStateFlow<ImmutableList<Long>>(persistentListOf())
|
private val selectedIds = MutableStateFlow<ImmutableList<Long>>(persistentListOf())
|
||||||
val selectedItems = combine(updates, _selectedIds) { updates, selectedItems ->
|
val selectedItems = combine(updates, selectedIds) { updates, selectedItems ->
|
||||||
updates.asSequence()
|
updates.asSequence()
|
||||||
.filterIsInstance<UpdatesUI.Item>()
|
.filterIsInstance<UpdatesUI.Item>()
|
||||||
.filter { it.chapterDownloadItem.isSelected(selectedItems) }
|
.filter { it.chapterDownloadItem.isSelected(selectedItems) }
|
||||||
@@ -73,7 +73,7 @@ class UpdatesScreenViewModel(
|
|||||||
.toImmutableList()
|
.toImmutableList()
|
||||||
}.stateIn(scope, SharingStarted.Eagerly, persistentListOf())
|
}.stateIn(scope, SharingStarted.Eagerly, persistentListOf())
|
||||||
|
|
||||||
val inActionMode = _selectedIds.map { it.isNotEmpty() }
|
val inActionMode = selectedIds.map { it.isNotEmpty() }
|
||||||
.stateIn(scope, SharingStarted.Eagerly, false)
|
.stateIn(scope, SharingStarted.Eagerly, false)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@@ -119,13 +119,13 @@ class UpdatesScreenViewModel(
|
|||||||
) {
|
) {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
updateChapter.await(chapterIds, read = read, onError = { toast(it.message.orEmpty()) })
|
updateChapter.await(chapterIds, read = read, onError = { toast(it.message.orEmpty()) })
|
||||||
_selectedIds.value = persistentListOf()
|
selectedIds.value = persistentListOf()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun markRead(id: Long?) = setRead(listOfNotNull(id).ifEmpty { _selectedIds.value }, true)
|
fun markRead(id: Long?) = setRead(listOfNotNull(id).ifEmpty { selectedIds.value }, true)
|
||||||
|
|
||||||
fun markUnread(id: Long?) = setRead(listOfNotNull(id).ifEmpty { _selectedIds.value }, false)
|
fun markUnread(id: Long?) = setRead(listOfNotNull(id).ifEmpty { selectedIds.value }, false)
|
||||||
|
|
||||||
private fun setBookmarked(
|
private fun setBookmarked(
|
||||||
chapterIds: List<Long>,
|
chapterIds: List<Long>,
|
||||||
@@ -133,20 +133,20 @@ class UpdatesScreenViewModel(
|
|||||||
) {
|
) {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
updateChapter.await(chapterIds, bookmarked = bookmark, onError = { toast(it.message.orEmpty()) })
|
updateChapter.await(chapterIds, bookmarked = bookmark, onError = { toast(it.message.orEmpty()) })
|
||||||
_selectedIds.value = persistentListOf()
|
selectedIds.value = persistentListOf()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bookmarkChapter(id: Long?) = setBookmarked(listOfNotNull(id).ifEmpty { _selectedIds.value }, true)
|
fun bookmarkChapter(id: Long?) = setBookmarked(listOfNotNull(id).ifEmpty { selectedIds.value }, true)
|
||||||
|
|
||||||
fun unBookmarkChapter(id: Long?) = setBookmarked(listOfNotNull(id).ifEmpty { _selectedIds.value }, false)
|
fun unBookmarkChapter(id: Long?) = setBookmarked(listOfNotNull(id).ifEmpty { selectedIds.value }, false)
|
||||||
|
|
||||||
fun downloadChapter(chapter: Chapter?) {
|
fun downloadChapter(chapter: Chapter?) {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
if (chapter == null) {
|
if (chapter == null) {
|
||||||
val selectedIds = _selectedIds.value
|
val selectedIds = selectedIds.value
|
||||||
batchChapterDownload.await(selectedIds, onError = { toast(it.message.orEmpty()) })
|
batchChapterDownload.await(selectedIds, onError = { toast(it.message.orEmpty()) })
|
||||||
_selectedIds.value = persistentListOf()
|
this@UpdatesScreenViewModel.selectedIds.value = persistentListOf()
|
||||||
return@launch
|
return@launch
|
||||||
}
|
}
|
||||||
queueChapterDownload.await(chapter.id, onError = { toast(it.message.orEmpty()) })
|
queueChapterDownload.await(chapter.id, onError = { toast(it.message.orEmpty()) })
|
||||||
@@ -156,12 +156,12 @@ class UpdatesScreenViewModel(
|
|||||||
fun deleteDownloadedChapter(chapter: Chapter?) {
|
fun deleteDownloadedChapter(chapter: Chapter?) {
|
||||||
scope.launchDefault {
|
scope.launchDefault {
|
||||||
if (chapter == null) {
|
if (chapter == null) {
|
||||||
val selectedIds = _selectedIds.value
|
val selectedIds = selectedIds.value
|
||||||
deleteChapterDownload.await(selectedIds, onError = { toast(it.message.orEmpty()) })
|
deleteChapterDownload.await(selectedIds, onError = { toast(it.message.orEmpty()) })
|
||||||
selectedItems.value.forEach {
|
selectedItems.value.forEach {
|
||||||
it.setNotDownloaded()
|
it.setNotDownloaded()
|
||||||
}
|
}
|
||||||
_selectedIds.value = persistentListOf()
|
this@UpdatesScreenViewModel.selectedIds.value = persistentListOf()
|
||||||
return@launchDefault
|
return@launchDefault
|
||||||
}
|
}
|
||||||
updates.value
|
updates.value
|
||||||
@@ -190,7 +190,7 @@ class UpdatesScreenViewModel(
|
|||||||
|
|
||||||
fun selectAll() {
|
fun selectAll() {
|
||||||
scope.launchDefault {
|
scope.launchDefault {
|
||||||
_selectedIds.value = updates.value.filterIsInstance<UpdatesUI.Item>()
|
selectedIds.value = updates.value.filterIsInstance<UpdatesUI.Item>()
|
||||||
.map { it.chapterDownloadItem.chapter.id }
|
.map { it.chapterDownloadItem.chapter.id }
|
||||||
.toImmutableList()
|
.toImmutableList()
|
||||||
}
|
}
|
||||||
@@ -198,28 +198,28 @@ class UpdatesScreenViewModel(
|
|||||||
|
|
||||||
fun invertSelection() {
|
fun invertSelection() {
|
||||||
scope.launchDefault {
|
scope.launchDefault {
|
||||||
_selectedIds.value = updates.value.filterIsInstance<UpdatesUI.Item>()
|
selectedIds.value = updates.value.filterIsInstance<UpdatesUI.Item>()
|
||||||
.map { it.chapterDownloadItem.chapter.id }
|
.map { it.chapterDownloadItem.chapter.id }
|
||||||
.minus(_selectedIds.value)
|
.minus(selectedIds.value)
|
||||||
.toImmutableList()
|
.toImmutableList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun selectChapter(id: Long) {
|
fun selectChapter(id: Long) {
|
||||||
scope.launchDefault {
|
scope.launchDefault {
|
||||||
_selectedIds.value = _selectedIds.value.plus(id).toImmutableList()
|
selectedIds.value = selectedIds.value.plus(id).toImmutableList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun unselectChapter(id: Long) {
|
fun unselectChapter(id: Long) {
|
||||||
scope.launchDefault {
|
scope.launchDefault {
|
||||||
_selectedIds.value = _selectedIds.value.minus(id).toImmutableList()
|
selectedIds.value = selectedIds.value.minus(id).toImmutableList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clearSelection() {
|
fun clearSelection() {
|
||||||
scope.launchDefault {
|
scope.launchDefault {
|
||||||
_selectedIds.value = persistentListOf()
|
selectedIds.value = persistentListOf()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user