@@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
22import { createSelector , MemoizedSelector , select , Store } from '@ngrx/store' ;
33import { AppState , keySelector } from '../../app.reducer' ;
44import { combineLatest as observableCombineLatest , Observable } from 'rxjs' ;
5- import { filter , map , switchMap , take } from 'rxjs/operators' ;
5+ import { distinctUntilChanged , filter , map , switchMap , take } from 'rxjs/operators' ;
66import {
77 ActivateMenuSectionAction ,
88 AddMenuSectionAction ,
@@ -23,6 +23,7 @@ import { MenuSections } from './menu-sections.model';
2323import { MenuSection } from './menu-section.model' ;
2424import { MenuID } from './menu-id.model' ;
2525import { ActivatedRoute , NavigationEnd , Router } from '@angular/router' ;
26+ import { compareArraysUsingIds } from '../../item-page/simple/item-types/shared/item-relationships-utils' ;
2627
2728export function menuKeySelector < T > ( key : string , selector ) : MemoizedSelector < MenuState , T > {
2829 return createSelector ( selector , ( state ) => {
@@ -81,8 +82,10 @@ export class MenuService {
8182 return this . store . pipe (
8283 select ( menuByIDSelector ( menuID ) ) ,
8384 select ( menuSectionStateSelector ) ,
84- map ( ( sections : MenuSections ) => {
85- return Object . values ( sections )
85+ map ( ( sections : MenuSections ) => Object . values ( sections ) ) ,
86+ distinctUntilChanged ( compareArraysUsingIds ( ) ) ,
87+ map ( ( sections : MenuSection [ ] ) => {
88+ return sections
8689 . filter ( ( section : MenuSection ) => hasNoValue ( section . parentID ) )
8790 . filter ( ( section : MenuSection ) => ! mustBeVisible || section . visible ) ;
8891 }
0 commit comments