Initialize entityOptions based on runtime entity type (Library or Shelf)
This commit is contained in:
committed by
Aditya Chandel
parent
9e6640f27f
commit
9289839601
@@ -138,10 +138,16 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
||||
map(({entityType}) => entityType)
|
||||
);
|
||||
|
||||
this.entity$.subscribe(entity => {
|
||||
this.entity = entity;
|
||||
this.entityOptions = this.libraryShelfMenuService.initializeLibraryMenuItems(entity);
|
||||
this.setSelectedSortFromEntity(entity);
|
||||
this.entity$?.subscribe((entity) => {
|
||||
if (!entity) {
|
||||
this.entityOptions = [];
|
||||
return;
|
||||
}
|
||||
if (this.isLibrary(entity)) {
|
||||
this.entityOptions = this.libraryShelfMenuService.initializeLibraryMenuItems(entity);
|
||||
} else {
|
||||
this.entityOptions = this.libraryShelfMenuService.initializeShelfMenuItems(entity);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -153,6 +159,10 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
||||
});
|
||||
}
|
||||
|
||||
private isLibrary(entity: Library | Shelf): entity is Library {
|
||||
return (entity as Library).paths !== undefined;
|
||||
}
|
||||
|
||||
toggleTableGrid() {
|
||||
this.gridOrTable = this.gridOrTable === 'grid' ? 'table' : 'grid';
|
||||
}
|
||||
@@ -183,7 +193,6 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
||||
if (entityType == EntityType.LIBRARY) {
|
||||
return this.fetchLibrary(entityId);
|
||||
} else if (EntityType.SHELF) {
|
||||
this.libraryShelfMenuService.initializeLibraryMenuItems(this.entity);
|
||||
return this.fetchShelf(entityId);
|
||||
}
|
||||
return of(null);
|
||||
|
||||
Reference in New Issue
Block a user