mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-23 21:27:40 +03:00
Fix notification and add visual cues when triggering a second update (#7783)
This commit is contained in:
parent
80b4b7bee6
commit
1f34f5277c
6 changed files with 21 additions and 21 deletions
|
@ -35,7 +35,7 @@ fun LibraryScreen(
|
|||
onClickSelectAll: () -> Unit,
|
||||
onClickInvertSelection: () -> Unit,
|
||||
onClickFilter: () -> Unit,
|
||||
onClickRefresh: (Category?) -> Unit,
|
||||
onClickRefresh: (Category?) -> Boolean,
|
||||
) {
|
||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
||||
val insets = WindowInsets.navigationBars.only(WindowInsetsSides.Horizontal)
|
||||
|
|
|
@ -42,7 +42,7 @@ fun LibraryContent(
|
|||
onChangeCurrentPage: (Int) -> Unit,
|
||||
onMangaClicked: (Long) -> Unit,
|
||||
onToggleSelection: (LibraryManga) -> Unit,
|
||||
onRefresh: (Category?) -> Unit,
|
||||
onRefresh: (Category?) -> Boolean,
|
||||
onGlobalSearchClicked: () -> Unit,
|
||||
getNumberOfMangaForCategory: @Composable (Long) -> State<Int?>,
|
||||
getDisplayModeForPage: @Composable (Int) -> State<DisplayModeSetting>,
|
||||
|
@ -84,7 +84,8 @@ fun LibraryContent(
|
|||
SwipeRefresh(
|
||||
state = rememberSwipeRefreshState(isRefreshing = isRefreshing),
|
||||
onRefresh = {
|
||||
onRefresh(categories[currentPage()])
|
||||
val started = onRefresh(categories[currentPage()])
|
||||
if (!started) return@SwipeRefresh
|
||||
scope.launch {
|
||||
// Fake refresh status but hide it after a second as it's a long running task
|
||||
isRefreshing = true
|
||||
|
|
|
@ -83,9 +83,9 @@ fun UpdateScreen(
|
|||
val context = LocalContext.current
|
||||
|
||||
val onUpdateLibrary = {
|
||||
if (LibraryUpdateService.start(context)) {
|
||||
context.toast(R.string.updating_library)
|
||||
}
|
||||
val started = LibraryUpdateService.start(context)
|
||||
context.toast(if (started) R.string.updating_library else R.string.update_already_running)
|
||||
started
|
||||
}
|
||||
|
||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
||||
|
@ -97,7 +97,7 @@ fun UpdateScreen(
|
|||
UpdatesAppBar(
|
||||
incognitoMode = presenter.isIncognitoMode,
|
||||
downloadedOnlyMode = presenter.isDownloadOnly,
|
||||
onUpdateLibrary = onUpdateLibrary,
|
||||
onUpdateLibrary = { onUpdateLibrary() },
|
||||
actionModeCounter = presenter.selected.size,
|
||||
onSelectAll = { presenter.toggleAllSelection(true) },
|
||||
onInvertSelection = { presenter.invertSelection() },
|
||||
|
@ -132,7 +132,8 @@ fun UpdateScreen(
|
|||
SwipeRefresh(
|
||||
state = rememberSwipeRefreshState(isRefreshing = isRefreshing),
|
||||
onRefresh = {
|
||||
onUpdateLibrary()
|
||||
val started = onUpdateLibrary()
|
||||
if (!started) return@SwipeRefresh
|
||||
scope.launch {
|
||||
// Fake refresh status but hide it after a second as it's a long running task
|
||||
isRefreshing = true
|
||||
|
|
|
@ -154,18 +154,15 @@ class LibraryUpdateService(
|
|||
* @return true if service newly started, false otherwise
|
||||
*/
|
||||
fun start(context: Context, category: Category? = null, target: Target = Target.CHAPTERS): Boolean {
|
||||
return if (!isRunning(context)) {
|
||||
val intent = Intent(context, LibraryUpdateService::class.java).apply {
|
||||
putExtra(KEY_TARGET, target)
|
||||
category?.let { putExtra(KEY_CATEGORY, it.id) }
|
||||
}
|
||||
ContextCompat.startForegroundService(context, intent)
|
||||
if (isRunning(context)) return false
|
||||
|
||||
true
|
||||
} else {
|
||||
instance?.addMangaToQueue(category?.id ?: -1)
|
||||
false
|
||||
val intent = Intent(context, LibraryUpdateService::class.java).apply {
|
||||
putExtra(KEY_TARGET, target)
|
||||
category?.let { putExtra(KEY_CATEGORY, it.id) }
|
||||
}
|
||||
ContextCompat.startForegroundService(context, intent)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -57,9 +57,9 @@ class LibraryController(
|
|||
onDeleteClicked = ::showDeleteMangaDialog,
|
||||
onClickFilter = ::showSettingsSheet,
|
||||
onClickRefresh = {
|
||||
if (LibraryUpdateService.start(context, it)) {
|
||||
context.toast(R.string.updating_library)
|
||||
}
|
||||
val started = LibraryUpdateService.start(context, it)
|
||||
context.toast(if (started) R.string.updating_library else R.string.update_already_running)
|
||||
started
|
||||
},
|
||||
onClickInvertSelection = { presenter.invertSelection(presenter.activeCategory) },
|
||||
onClickSelectAll = { presenter.selectAll(presenter.activeCategory) },
|
||||
|
|
|
@ -729,6 +729,7 @@
|
|||
|
||||
<!-- Updates fragment -->
|
||||
<string name="updating_library">Updating library</string>
|
||||
<string name="update_already_running">An update is already running</string>
|
||||
<string name="cant_open_last_read_chapter">Unable to open last read chapter</string>
|
||||
|
||||
<!-- History fragment -->
|
||||
|
|
Loading…
Reference in a new issue