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