@@ -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 { map , switchMap } from 'rxjs/operators' ;
5+ import { distinctUntilChanged , map , switchMap } from 'rxjs/operators' ;
66import {
77 ActivateMenuSectionAction ,
88 AddMenuSectionAction ,
@@ -22,6 +22,7 @@ import { MenuState } from './menu-state.model';
2222import { MenuSections } from './menu-sections.model' ;
2323import { MenuSection } from './menu-section.model' ;
2424import { MenuID } from './menu-id.model' ;
25+ import { compareArraysUsingIds } from '../../item-page/simple/item-types/shared/item-relationships-utils' ;
2526
2627export function menuKeySelector < T > ( key : string , selector ) : MemoizedSelector < MenuState , T > {
2728 return createSelector ( selector , ( state ) => {
@@ -76,8 +77,10 @@ export class MenuService {
7677 return this . store . pipe (
7778 select ( menuByIDSelector ( menuID ) ) ,
7879 select ( menuSectionStateSelector ) ,
79- map ( ( sections : MenuSections ) => {
80- return Object . values ( sections )
80+ map ( ( sections : MenuSections ) => Object . values ( sections ) ) ,
81+ distinctUntilChanged ( compareArraysUsingIds ( ) ) ,
82+ map ( ( sections : MenuSection [ ] ) => {
83+ return sections
8184 . filter ( ( section : MenuSection ) => hasNoValue ( section . parentID ) )
8285 . filter ( ( section : MenuSection ) => ! mustBeVisible || section . visible ) ;
8386 }
0 commit comments