mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
chore(manga): Try not to use GlobalScope as much as possible
This commit is contained in:
parent
28cbf0b988
commit
823860a56f
1 changed files with 5 additions and 2 deletions
|
@ -191,6 +191,7 @@ suspend fun Manga.addOrRemoveToFavorites(
|
||||||
migrateManga = { source, faved ->
|
migrateManga = { source, faved ->
|
||||||
onMangaAdded(source to faved)
|
onMangaAdded(source to faved)
|
||||||
},
|
},
|
||||||
|
scope = scope,
|
||||||
)
|
)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
@ -376,6 +377,8 @@ private suspend fun showAddDuplicateDialog(
|
||||||
controller: Controller,
|
controller: Controller,
|
||||||
addManga: suspend () -> Unit,
|
addManga: suspend () -> Unit,
|
||||||
migrateManga: (Long, Boolean) -> Unit,
|
migrateManga: (Long, Boolean) -> Unit,
|
||||||
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
|
scope: CoroutineScope = GlobalScope,
|
||||||
) = withUIContext {
|
) = withUIContext {
|
||||||
val source = sourceManager.getOrStub(libraryManga.source)
|
val source = sourceManager.getOrStub(libraryManga.source)
|
||||||
|
|
||||||
|
@ -385,7 +388,7 @@ private suspend fun showAddDuplicateDialog(
|
||||||
val enabled = titles.indices.map { listView.isItemChecked(it) }.toTypedArray()
|
val enabled = titles.indices.map { listView.isItemChecked(it) }.toTypedArray()
|
||||||
val flags = MigrationFlags.getFlagsFromPositions(enabled, libraryManga)
|
val flags = MigrationFlags.getFlagsFromPositions(enabled, libraryManga)
|
||||||
val enhancedServices by lazy { Injekt.get<TrackManager>().services.filterIsInstance<EnhancedTrackService>() }
|
val enhancedServices by lazy { Injekt.get<TrackManager>().services.filterIsInstance<EnhancedTrackService>() }
|
||||||
launchUI {
|
scope.launchUI {
|
||||||
MigrationProcessAdapter.migrateMangaInternal(
|
MigrationProcessAdapter.migrateMangaInternal(
|
||||||
flags,
|
flags,
|
||||||
enhancedServices,
|
enhancedServices,
|
||||||
|
@ -415,7 +418,7 @@ private suspend fun showAddDuplicateDialog(
|
||||||
MangaDetailsController(libraryManga)
|
MangaDetailsController(libraryManga)
|
||||||
.withFadeTransaction(),
|
.withFadeTransaction(),
|
||||||
)
|
)
|
||||||
1 -> launchIO { addManga() }
|
1 -> scope.launchIO { addManga() }
|
||||||
2 -> {
|
2 -> {
|
||||||
if (!newManga.initialized) {
|
if (!newManga.initialized) {
|
||||||
activity.toast(MR.strings.must_view_details_before_migration, Toast.LENGTH_LONG)
|
activity.toast(MR.strings.must_view_details_before_migration, Toast.LENGTH_LONG)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue