File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 <Icon icon =" nav" />
55 </button >
66
7- <SearchForm class =" flex-grow-1 flex-md-grow-0 ms-auto me-2" />
7+ <div class =" d-none d-md-block ms-auto" >
8+ <span v-if =" isScanning" class =" spinner-border me-2" title =" Scanning…" />
9+ </div >
10+
11+ <SearchForm class =" flex-grow-1 flex-md-grow-0 me-2" />
812
913 <template v-if =" store .username " >
1014 <Dropdown variant =" link" align =" end" no-caret toggle-class =" px-0" >
4145 import SearchForm from ' @/library/search/SearchForm.vue'
4246 import { useMainStore } from ' @/shared/store'
4347 import { useAuth } from ' @/auth/service'
48+ import { sleep } from ' @/shared/utils'
4449
4550 export default defineComponent ({
4651 components: {
5560 },
5661 data() {
5762 return {
58- showAboutModal: false
63+ isScanning: false ,
64+ showAboutModal: false ,
5965 }
6066 },
6167 methods: {
62- scan() {
63- return this .$api .scan ()
68+ async scan() {
69+ if (this .isScanning ) {
70+ return
71+ }
72+ this .isScanning = true
73+ try {
74+ await this .$api .scan ()
75+ let scanning = false
76+ do {
77+ await sleep (1000 )
78+ scanning = await this .$api .getScanStatus ()
79+ } while (scanning )
80+ } finally {
81+ this .isScanning = false
82+ }
6483 },
6584 logout() {
6685 this .auth .logout ()
Original file line number Diff line number Diff line change @@ -516,6 +516,11 @@ export class API {
516516 return this . fetch ( 'rest/startScan' )
517517 }
518518
519+ async getScanStatus ( ) : Promise < boolean > {
520+ const response = await this . fetch ( 'rest/getScanStatus' )
521+ return response . scanStatus . scanning
522+ }
523+
519524 async scrobble ( id : string ) : Promise < void > {
520525 return this . fetch ( 'rest/scrobble' , { id, submission : true } )
521526 }
Original file line number Diff line number Diff line change @@ -63,3 +63,7 @@ export function formatDuration(value: number): string {
6363 const seconds = Math . floor ( value % 60 )
6464 return ( minutes < 10 ? '0' : '' ) + minutes + ':' + ( seconds < 10 ? '0' : '' ) + seconds
6565}
66+
67+ export function sleep ( ms : number ) {
68+ return new Promise ( resolve => setTimeout ( resolve , ms ) )
69+ }
You can’t perform that action at this time.
0 commit comments