diff --git a/src/renderer/components/+catalog/catalog-entity.store.ts b/src/renderer/components/+catalog/catalog-entity.store.ts index 1cc724a125..ea705c98dc 100644 --- a/src/renderer/components/+catalog/catalog-entity.store.ts +++ b/src/renderer/components/+catalog/catalog-entity.store.ts @@ -64,7 +64,7 @@ export class CatalogEntityItem implements ItemObject { } export class CatalogEntityStore extends ItemStore { - @observable activeCategory: CatalogCategory; + @observable activeCategory?: CatalogCategory; constructor() { super(); @@ -73,7 +73,9 @@ export class CatalogEntityStore extends ItemStore { } @computed get entities() { - if (!this.activeCategory) return []; + if (!this.activeCategory) { + return catalogEntityRegistry.items.map(entity => new CatalogEntityItem(entity)); + } return catalogEntityRegistry.getItemsForCategory(this.activeCategory).map(entity => new CatalogEntityItem(entity)); } diff --git a/src/renderer/components/+catalog/catalog.tsx b/src/renderer/components/+catalog/catalog.tsx index 752a34bb5a..61f6936973 100644 --- a/src/renderer/components/+catalog/catalog.tsx +++ b/src/renderer/components/+catalog/catalog.tsx @@ -28,7 +28,7 @@ enum sortBy { export class Catalog extends React.Component { @observable private catalogEntityStore?: CatalogEntityStore; @observable private contextMenu: CatalogEntityContextMenuContext; - @observable activeTab: string; + @observable activeTab?: string; constructor(props: object) { super(props); @@ -82,14 +82,11 @@ export class Catalog extends React.Component { } @action - onTabChange = (tabId: string) => { - this.activeTab = tabId; + onTabChange = (tabId: string | null) => { + const activeCategory = this.categories.find(category => category.getId() === tabId); - const activeCategory = this.categories.find((category) => category.getId() === tabId); - - if (activeCategory) { - this.catalogEntityStore.activeCategory = activeCategory; - } + this.catalogEntityStore.activeCategory = activeCategory; + this.activeTab = activeCategory?.getId(); }; renderNavigation() { @@ -97,9 +94,19 @@ export class Catalog extends React.Component {
Catalog
- {this.categories.map((category, index) => { - return ; - })} + + {this.categories.map(category => ( + + )) + }
); @@ -108,22 +115,18 @@ export class Catalog extends React.Component { @autobind() renderItemMenu(item: CatalogEntityItem) { const menuItems = this.contextMenu.menuItems.filter((menuItem) => !menuItem.onlyVisibleForSource || menuItem.onlyVisibleForSource === item.entity.metadata.source); - const onOpen = async () => { - await item.onContextMenuOpen(this.contextMenu); - }; return ( - onOpen()}> + item.onContextMenuOpen(this.contextMenu)}> this.addToHotbar(item)}> Add to Hotbar - {menuItems.map((menuItem, index) => { - return ( + {menuItems.map((menuItem, index) => ( this.onMenuItemClick(menuItem)}> - {menuItem.title} + {menuItem.title} - ); - })} + )) + } ); } @@ -140,7 +143,7 @@ export class Catalog extends React.Component { provideBackButtonNavigation={false} contentGaps={false}>