Browse Source

fix(admin-ui): Fix navigation to order list component

Michael Bromley 2 years ago
parent
commit
9b4821ef04

+ 8 - 1
packages/admin-ui/src/lib/core/src/providers/breadcrumb/breadcrumb.service.ts

@@ -2,7 +2,13 @@ import { Injectable, OnDestroy } from '@angular/core';
 import { ActivatedRoute, Data, NavigationEnd, Params, PRIMARY_OUTLET, Router } from '@angular/router';
 import { DataService } from '@vendure/admin-ui/core';
 import { flatten } from 'lodash';
-import { combineLatest as observableCombineLatest, Observable, of as observableOf, Subject } from 'rxjs';
+import {
+    combineLatest as observableCombineLatest,
+    Observable,
+    of as observableOf,
+    share,
+    Subject,
+} from 'rxjs';
 import { filter, map, startWith, switchMap, takeUntil } from 'rxjs/operators';
 
 export type BreadcrumbString = string;
@@ -33,6 +39,7 @@ export class BreadcrumbService implements OnDestroy {
             takeUntil(this.destroy$),
             startWith(true),
             switchMap(() => this.generateBreadcrumbs(this.route.root)),
+            share(),
         );
     }
 

+ 4 - 4
packages/admin-ui/src/lib/order/src/components/order-list/order-list.component.ts

@@ -115,10 +115,6 @@ export class OrderListComponent
                     this.route.snapshot.queryParamMap.get('filter') || 'open',
                 ),
         );
-        const lastFilters = this.localStorageService.get('orderListLastCustomFilters');
-        if (lastFilters) {
-            this.setQueryParam(lastFilters, { replaceUrl: true });
-        }
         this.canCreateDraftOrder = !!this.serverConfigService
             .getOrderProcessStates()
             .find(state => state.name === 'Created')
@@ -130,6 +126,10 @@ export class OrderListComponent
 
     ngOnInit() {
         super.ngOnInit();
+        const lastFilters = this.localStorageService.get('orderListLastCustomFilters');
+        if (lastFilters) {
+            this.setQueryParam(lastFilters, { replaceUrl: true });
+        }
         this.activePreset$ = this.route.queryParamMap.pipe(
             map(qpm => qpm.get('filter') || 'open'),
             distinctUntilChanged(),