From c5b22c8cbed6acb76be44e2c2b78c2cf3dabefed Mon Sep 17 00:00:00 2001 From: Janne Savolainen Date: Wed, 6 Apr 2022 10:30:55 +0300 Subject: [PATCH] Fix navigating back to tab in catalog from hotbar Co-authored-by: Mikko Aspiala Signed-off-by: Janne Savolainen --- src/renderer/components/+catalog/catalog.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/renderer/components/+catalog/catalog.tsx b/src/renderer/components/+catalog/catalog.tsx index 784aa1ba45..b7638e34eb 100644 --- a/src/renderer/components/+catalog/catalog.tsx +++ b/src/renderer/components/+catalog/catalog.tsx @@ -42,7 +42,7 @@ import hotbarStoreInjectable from "../../../common/hotbar-store.injectable"; import type { HotbarStore } from "../../../common/hotbar-store"; interface Dependencies { - catalogPreviousActiveTabStorage: { set: (value: string ) => void }; + catalogPreviousActiveTabStorage: { set: (value: string ) => void; get: () => string }; catalogEntityStore: CatalogEntityStore; getCategoryColumns: (params: GetCategoryColumnsParams) => CategoryColumns; customCategoryViews: IComputedValue>>; @@ -78,6 +78,12 @@ class NonInjectedCatalog extends React.Component { return `${dereferencedGroup}/${dereferencedKind}`; } + const previousTab = this.props.catalogPreviousActiveTabStorage.get(); + + if (previousTab) { + return previousTab; + } + return browseCatalogTab; } @@ -89,8 +95,6 @@ class NonInjectedCatalog extends React.Component { disposeOnUnmount(this, [ this.props.catalogEntityStore.watch(), reaction(() => this.routeActiveTab, async (routeTab) => { - this.props.catalogPreviousActiveTabStorage.set(this.routeActiveTab); - try { await when(() => (routeTab === browseCatalogTab || !!catalogCategoryRegistry.filteredItems.find(i => i.getId() === routeTab)), { timeout: 5_000 }); // we need to wait because extensions might take a while to load const item = catalogCategoryRegistry.filteredItems.find(i => i.getId() === routeTab); @@ -175,9 +179,10 @@ class NonInjectedCatalog extends React.Component { }); if (activeCategory) { - + this.props.catalogPreviousActiveTabStorage.set(`${activeCategory.spec.group}/${activeCategory.spec.names.kind}`); this.props.navigateToCatalog({ group: activeCategory.spec.group, kind: activeCategory.spec.names.kind }); } else { + this.props.catalogPreviousActiveTabStorage.set(null); this.props.navigateToCatalog({ group: browseCatalogTab }); } });