From b8ed56e91e2a44bc56d6af7ac8f5cc91475bd6f6 Mon Sep 17 00:00:00 2001 From: advplyr Date: Mon, 13 May 2024 16:31:30 -0500 Subject: [PATCH] Update:Using translations for scan buttons shown on empty library pages & add loading indicator --- .../components/app/BookShelfCategorized.vue | 21 ++++++++++++------- client/components/app/LazyBookshelf.vue | 19 ++++++++++------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/client/components/app/BookShelfCategorized.vue b/client/components/app/BookShelfCategorized.vue index eb4e9424..0c4562a4 100644 --- a/client/components/app/BookShelfCategorized.vue +++ b/client/components/app/BookShelfCategorized.vue @@ -4,10 +4,10 @@
-

{{ libraryName }} Library is empty!

+

{{ $getString('MessageXLibraryIsEmpty', [libraryName]) }}

- Configure Scanner - Scan Library + {{ $strings.ButtonConfigureScanner }} + {{ $strings.ButtonScanLibrary }}
@@ -58,7 +58,8 @@ export default { scannerParseSubtitle: false, wrapperClientWidth: 0, shelves: [], - lastItemIndexSelected: -1 + lastItemIndexSelected: -1, + tempIsScanning: false } }, computed: { @@ -97,6 +98,9 @@ export default { }, streamLibraryItem() { return this.$store.state.streamLibraryItem + }, + isScanningLibrary() { + return !!this.$store.getters['tasks/getRunningLibraryScanTask'](this.currentLibraryId) } }, methods: { @@ -273,14 +277,15 @@ export default { this.shelves = shelves }, scan() { + this.tempIsScanning = true this.$store .dispatch('libraries/requestLibraryScan', { libraryId: this.$store.state.libraries.currentLibraryId }) - .then(() => { - this.$toast.success('Library scan started') - }) .catch((error) => { console.error('Failed to start scan', error) - this.$toast.error('Failed to start scan') + this.$toast.error(this.$strings.ToastLibraryScanFailedToStart) + }) + .finally(() => { + this.tempIsScanning = false }) }, userUpdated(user) { diff --git a/client/components/app/LazyBookshelf.vue b/client/components/app/LazyBookshelf.vue index 5291cdbb..805c6978 100644 --- a/client/components/app/LazyBookshelf.vue +++ b/client/components/app/LazyBookshelf.vue @@ -10,7 +10,7 @@

{{ $getString('MessageXLibraryIsEmpty', [libraryName]) }}

{{ $strings.ButtonConfigureScanner }} - {{ $strings.ButtonScanLibrary }} + {{ $strings.ButtonScanLibrary }}
@@ -62,7 +62,8 @@ export default { currScrollTop: 0, resizeTimeout: null, mountWindowWidth: 0, - lastItemIndexSelected: -1 + lastItemIndexSelected: -1, + tempIsScanning: false } }, watch: { @@ -208,6 +209,9 @@ export default { }, streamLibraryItem() { return this.$store.state.streamLibraryItem + }, + isScanningLibrary() { + return !!this.$store.getters['tasks/getRunningLibraryScanTask'](this.currentLibraryId) } }, methods: { @@ -727,14 +731,15 @@ export default { } }, scan() { + this.tempIsScanning = true this.$store .dispatch('libraries/requestLibraryScan', { libraryId: this.currentLibraryId }) - .then(() => { - this.$toast.success('Library scan started') - }) .catch((error) => { console.error('Failed to start scan', error) - this.$toast.error('Failed to start scan') + this.$toast.error(this.$strings.ToastLibraryScanFailedToStart) + }) + .finally(() => { + this.tempIsScanning = false }) } }, @@ -775,4 +780,4 @@ export default { background: var(--bookshelf-divider-bg); box-shadow: 2px 14px 8px #111111aa; } - \ No newline at end of file +