mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-22 21:02:16 +03:00
parent
7834b18298
commit
aeeecad486
17 changed files with 74 additions and 45 deletions
|
@ -31,30 +31,33 @@ class DelayedAnimeTrackingUpdateJob(context: Context, workerParams: WorkerParame
|
|||
val trackManager = Injekt.get<TrackManager>()
|
||||
val delayedTrackingStore = Injekt.get<DelayedAnimeTrackingStore>()
|
||||
|
||||
withIOContext {
|
||||
val tracks = delayedTrackingStore.getAnimeItems().mapNotNull {
|
||||
val track = getTracks.awaitOne(it.trackId)
|
||||
if (track == null) {
|
||||
delayedTrackingStore.removeAnimeItem(it.trackId)
|
||||
}
|
||||
track
|
||||
}
|
||||
|
||||
tracks.forEach { animeTrack ->
|
||||
try {
|
||||
val service = trackManager.getService(animeTrack.syncId)
|
||||
if (service != null && service.isLogged) {
|
||||
service.animeService.update(animeTrack.toDbTrack(), true)
|
||||
insertTrack.await(animeTrack)
|
||||
val results = withIOContext {
|
||||
delayedTrackingStore.getAnimeItems()
|
||||
.mapNotNull {
|
||||
val track = getTracks.awaitOne(it.trackId)
|
||||
if (track == null) {
|
||||
delayedTrackingStore.removeAnimeItem(it.trackId)
|
||||
}
|
||||
track?.copy(lastEpisodeSeen = it.lastEpisodeSeen.toDouble())
|
||||
}
|
||||
.mapNotNull { animeTrack ->
|
||||
try {
|
||||
val service = trackManager.getService(animeTrack.syncId)
|
||||
if (service != null && service.isLogged) {
|
||||
logcat(LogPriority.DEBUG) { "Updating delayed track item: ${animeTrack.id}, last episode seen: ${animeTrack.lastEpisodeSeen}" }
|
||||
service.animeService.update(animeTrack.toDbTrack(), true)
|
||||
insertTrack.await(animeTrack)
|
||||
}
|
||||
delayedTrackingStore.removeAnimeItem(animeTrack.id)
|
||||
null
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e)
|
||||
false
|
||||
}
|
||||
delayedTrackingStore.removeAnimeItem(animeTrack.id)
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Result.success()
|
||||
return if (results.isNotEmpty()) Result.failure() else Result.success()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -31,30 +31,33 @@ class DelayedMangaTrackingUpdateJob(context: Context, workerParams: WorkerParame
|
|||
val trackManager = Injekt.get<TrackManager>()
|
||||
val delayedTrackingStore = Injekt.get<DelayedMangaTrackingStore>()
|
||||
|
||||
withIOContext {
|
||||
val tracks = delayedTrackingStore.getMangaItems().mapNotNull {
|
||||
val track = getTracks.awaitOne(it.trackId)
|
||||
if (track == null) {
|
||||
delayedTrackingStore.removeMangaItem(it.trackId)
|
||||
}
|
||||
track
|
||||
}
|
||||
|
||||
tracks.forEach { track ->
|
||||
try {
|
||||
val service = trackManager.getService(track.syncId)
|
||||
if (service != null && service.isLogged) {
|
||||
service.mangaService.update(track.toDbTrack(), true)
|
||||
insertTrack.await(track)
|
||||
val results = withIOContext {
|
||||
delayedTrackingStore.getMangaItems()
|
||||
.mapNotNull {
|
||||
val track = getTracks.awaitOne(it.trackId)
|
||||
if (track == null) {
|
||||
delayedTrackingStore.removeMangaItem(it.trackId)
|
||||
}
|
||||
track?.copy(lastChapterRead = it.lastChapterRead.toDouble())
|
||||
}
|
||||
.mapNotNull { track ->
|
||||
try {
|
||||
val service = trackManager.getService(track.syncId)
|
||||
if (service != null && service.isLogged) {
|
||||
logcat(LogPriority.DEBUG) { "Updating delayed track item: ${track.id}, last chapter read: ${track.lastChapterRead}" }
|
||||
service.mangaService.update(track.toDbTrack(), true)
|
||||
insertTrack.await(track)
|
||||
}
|
||||
delayedTrackingStore.removeMangaItem(track.id)
|
||||
null
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e)
|
||||
false
|
||||
}
|
||||
delayedTrackingStore.removeMangaItem(track.id)
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Result.success()
|
||||
return if (results.isNotEmpty()) Result.failure() else Result.success()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -43,6 +43,7 @@ fun EntryToolbar(
|
|||
onClickShare: (() -> Unit)?,
|
||||
onClickDownload: ((DownloadAction) -> Unit)?,
|
||||
onClickEditCategory: (() -> Unit)?,
|
||||
onClickRefresh: () -> Unit,
|
||||
onClickMigrate: (() -> Unit)?,
|
||||
// Anime only
|
||||
changeAnimeSkipIntro: (() -> Unit)?,
|
||||
|
@ -112,8 +113,14 @@ fun EntryToolbar(
|
|||
Icon(Icons.Outlined.FilterList, contentDescription = stringResource(R.string.action_filter), tint = filterTint)
|
||||
}
|
||||
|
||||
if (onClickEditCategory != null || onClickMigrate != null || onClickShare != null || changeAnimeSkipIntro != null) {
|
||||
OverflowMenu { closeMenu ->
|
||||
OverflowMenu { closeMenu ->
|
||||
DropdownMenuItem(
|
||||
text = { Text(text = stringResource(R.string.action_webview_refresh)) },
|
||||
onClick = {
|
||||
onClickRefresh()
|
||||
closeMenu()
|
||||
},
|
||||
)
|
||||
if (onClickEditCategory != null) {
|
||||
DropdownMenuItem(
|
||||
text = { Text(text = stringResource(R.string.action_edit_categories)) },
|
||||
|
@ -150,7 +157,6 @@ fun EntryToolbar(
|
|||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -286,6 +286,7 @@ private fun AnimeScreenSmallImpl(
|
|||
onClickShare = onShareClicked,
|
||||
onClickDownload = onDownloadActionClicked,
|
||||
onClickEditCategory = onEditCategoryClicked,
|
||||
onClickRefresh = onRefresh,
|
||||
onClickMigrate = onMigrateClicked,
|
||||
changeAnimeSkipIntro = changeAnimeSkipIntro,
|
||||
actionModeCounter = episodes.count { it.selected },
|
||||
|
@ -518,6 +519,7 @@ fun AnimeScreenLargeImpl(
|
|||
onClickShare = onShareClicked,
|
||||
onClickDownload = onDownloadActionClicked,
|
||||
onClickEditCategory = onEditCategoryClicked,
|
||||
onClickRefresh = onRefresh,
|
||||
onClickMigrate = onMigrateClicked,
|
||||
changeAnimeSkipIntro = changeAnimeSkipIntro,
|
||||
actionModeCounter = episodes.count { it.selected },
|
||||
|
|
|
@ -277,6 +277,7 @@ private fun MangaScreenSmallImpl(
|
|||
onClickShare = onShareClicked,
|
||||
onClickDownload = onDownloadActionClicked,
|
||||
onClickEditCategory = onEditCategoryClicked,
|
||||
onClickRefresh = onRefresh,
|
||||
onClickMigrate = onMigrateClicked,
|
||||
changeAnimeSkipIntro = null,
|
||||
actionModeCounter = chapters.count { it.selected },
|
||||
|
@ -500,6 +501,7 @@ fun MangaScreenLargeImpl(
|
|||
onClickShare = onShareClicked,
|
||||
onClickDownload = onDownloadActionClicked,
|
||||
onClickEditCategory = onEditCategoryClicked,
|
||||
onClickRefresh = onRefresh,
|
||||
onClickMigrate = onMigrateClicked,
|
||||
changeAnimeSkipIntro = null,
|
||||
actionModeCounter = chapters.count { it.selected },
|
||||
|
|
|
@ -37,6 +37,7 @@ fun LibraryToolbar(
|
|||
onClickInvertSelection: () -> Unit,
|
||||
onClickFilter: () -> Unit,
|
||||
onClickRefresh: () -> Unit,
|
||||
onClickGlobalUpdate: () -> Unit,
|
||||
onClickOpenRandomEntry: () -> Unit,
|
||||
searchQuery: String?,
|
||||
onSearchQueryChange: (String?) -> Unit,
|
||||
|
@ -57,6 +58,7 @@ fun LibraryToolbar(
|
|||
onSearchQueryChange = onSearchQueryChange,
|
||||
onClickFilter = onClickFilter,
|
||||
onClickRefresh = onClickRefresh,
|
||||
onClickGlobalUpdate = onClickGlobalUpdate,
|
||||
onClickOpenRandomEntry = onClickOpenRandomEntry,
|
||||
scrollBehavior = scrollBehavior,
|
||||
navigateUp = navigateUp,
|
||||
|
@ -71,6 +73,7 @@ fun LibraryRegularToolbar(
|
|||
onSearchQueryChange: (String?) -> Unit,
|
||||
onClickFilter: () -> Unit,
|
||||
onClickRefresh: () -> Unit,
|
||||
onClickGlobalUpdate: () -> Unit,
|
||||
onClickOpenRandomEntry: () -> Unit,
|
||||
scrollBehavior: TopAppBarScrollBehavior?,
|
||||
navigateUp: (() -> Unit)? = null,
|
||||
|
@ -105,6 +108,13 @@ fun LibraryRegularToolbar(
|
|||
OverflowMenu { closeMenu ->
|
||||
DropdownMenuItem(
|
||||
text = { Text(text = stringResource(R.string.pref_category_library_update)) },
|
||||
onClick = {
|
||||
onClickGlobalUpdate()
|
||||
closeMenu()
|
||||
},
|
||||
)
|
||||
DropdownMenuItem(
|
||||
text = { Text(text = stringResource(R.string.action_update_category)) },
|
||||
onClick = {
|
||||
onClickRefresh()
|
||||
closeMenu()
|
||||
|
|
|
@ -151,7 +151,8 @@ object AnimeLibraryTab : Tab {
|
|||
onClickSelectAll = { screenModel.selectAll(screenModel.activeCategoryIndex) },
|
||||
onClickInvertSelection = { screenModel.invertSelection(screenModel.activeCategoryIndex) },
|
||||
onClickFilter = { screenModel.showSettingsDialog() },
|
||||
onClickRefresh = { onClickRefresh(null) },
|
||||
onClickRefresh = { onClickRefresh(state.categories[screenModel.activeCategoryIndex]) },
|
||||
onClickGlobalUpdate = { onClickRefresh(null) },
|
||||
onClickOpenRandomEntry = {
|
||||
scope.launch {
|
||||
val randomItem = screenModel.getRandomAnimelibItemForCurrentCategory()
|
||||
|
|
|
@ -133,7 +133,8 @@ object MangaLibraryTab : Tab {
|
|||
onClickSelectAll = { screenModel.selectAll(screenModel.activeCategoryIndex) },
|
||||
onClickInvertSelection = { screenModel.invertSelection(screenModel.activeCategoryIndex) },
|
||||
onClickFilter = { screenModel.showSettingsDialog() },
|
||||
onClickRefresh = { onClickRefresh(null) },
|
||||
onClickRefresh = { onClickRefresh(state.categories[screenModel.activeCategoryIndex]) },
|
||||
onClickGlobalUpdate = { onClickRefresh(null) },
|
||||
onClickOpenRandomEntry = {
|
||||
scope.launch {
|
||||
val randomItem = screenModel.getRandomLibraryItemForCurrentCategory()
|
||||
|
|
|
@ -74,6 +74,7 @@
|
|||
<string name="action_disable_all">Disable all</string>
|
||||
<string name="action_edit">Edit</string>
|
||||
<string name="action_add">Add</string>
|
||||
<string name="action_update_category">Update category</string>
|
||||
<string name="action_open_random_manga">Open random entry</string>
|
||||
<string name="action_add_category">Add category</string>
|
||||
<string name="action_edit_categories">Edit categories</string>
|
||||
|
|
Loading…
Reference in a new issue