Show a persistent loader while a large library is being created (#2200)
Co-authored-by: acx10 <acx10@users.noreply.github.com>
This commit is contained in:
@@ -22,6 +22,13 @@ export class LibraryService {
|
||||
error: null,
|
||||
});
|
||||
|
||||
private largeLibraryLoadingSubject = new BehaviorSubject<{ isLoading: boolean; expectedCount: number }>({
|
||||
isLoading: false,
|
||||
expectedCount: 0
|
||||
});
|
||||
|
||||
largeLibraryLoading$ = this.largeLibraryLoadingSubject.asObservable();
|
||||
|
||||
private loading$: Observable<Library[]> | null = null;
|
||||
|
||||
constructor() {
|
||||
@@ -72,6 +79,10 @@ export class LibraryService {
|
||||
);
|
||||
}
|
||||
|
||||
scanLibraryPaths(lib: Library): Observable<number> {
|
||||
return this.http.post<number>(`${this.url}/scan`, lib);
|
||||
}
|
||||
|
||||
createLibrary(lib: Library): Observable<Library> {
|
||||
return this.http.post<Library>(this.url, lib).pipe(
|
||||
map(created => {
|
||||
@@ -150,4 +161,8 @@ export class LibraryService {
|
||||
map(state => (state.books || []).filter(b => b.libraryId === libraryId).length)
|
||||
);
|
||||
}
|
||||
|
||||
setLargeLibraryLoading(isLoading: boolean, expectedCount: number): void {
|
||||
this.largeLibraryLoadingSubject.next({ isLoading, expectedCount });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user