Fix library creator component

This commit is contained in:
aditya.chandel
2025-01-02 16:02:36 -07:00
parent 0e6ef1da5e
commit 83d0a761ae
3 changed files with 13 additions and 11 deletions
+1 -1
View File
@@ -52,7 +52,7 @@ import { LoadingOverlayComponent } from './loading-overlay/loading-overlay.compo
LibraryCreatorComponent,
ShelfAssignerComponent,
BookBrowserComponent,
MetadataSearcherComponent
MetadataSearcherComponent,
],
imports: [
BrowserModule,
@@ -74,9 +74,7 @@ export class BookCardComponent implements OnInit {
{
label: 'View metadata',
icon: 'pi pi-info-circle',
command: () => {
this.openBookInfo(this.book)
},
command: () => this.openBookInfo(this.book),
},
],
},
@@ -98,6 +96,8 @@ export class BookCardComponent implements OnInit {
}
openBookInfo(book: Book): void {
this.router.navigate(['/library', book.libraryId, 'book', book.id, 'info']);
setTimeout(() => {
this.router.navigate(['/library', book.libraryId, 'book', book.id, 'info']);
}, 10);
}
}
@@ -5,6 +5,7 @@ import {MessageService} from 'primeng/api';
import {Router} from '@angular/router';
import {LibraryService} from '../../service/library.service';
import {IconPickerComponent} from '../icon-picker/icon-picker.component';
import {take} from 'rxjs';
@Component({
selector: 'app-library-creator',
@@ -97,10 +98,12 @@ export class LibraryCreatorComponent {
validateLibraryNameAndProceed(activateCallback: Function) {
if (this.libraryName.trim()) {
this.libraryService.libraryState$.subscribe(
libraryState => {
let library = libraryState.libraries?.find(library => library.name === this.libraryName.trim());
if(library) {
const libraryName = this.libraryName.trim();
this.libraryService.libraryState$
.pipe(take(1))
.subscribe(libraryState => {
const library = libraryState.libraries?.find(library => library.name === libraryName);
if (library) {
this.messageService.add({
severity: 'error',
summary: 'Library Name Exists',
@@ -109,8 +112,7 @@ export class LibraryCreatorComponent {
} else {
activateCallback(2);
}
}
)
});
}
}