Skip to content

Commit

Permalink
fix(daffio): remove extraneous api call to guides list. (#2735)
Browse files Browse the repository at this point in the history
  • Loading branch information
damienwebdev committed Jan 23, 2024
1 parent b219d31 commit 4b5acdd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ import {
} from '@daffodil/design/sidebar';

import { DaffioSidebarViewportContainer } from './sidebar-viewport.component';
import {
OpenSidebar,
CloseSidebar,
SetSidebarState,
} from '../../actions/sidebar.actions';
import { CloseSidebar } from '../../actions/sidebar.actions';
import * as fromSidebar from '../../reducers/index';

describe('DaffioSidebarViewportContainer', () => {
Expand Down Expand Up @@ -109,21 +105,5 @@ describe('DaffioSidebarViewportContainer', () => {
expect(store.dispatch).toHaveBeenCalledWith(new CloseSidebar());
});
});

describe('open', () => {
it('should call store.dispatch with a OpenSidebar action', () => {
component.open();

expect(store.dispatch).toHaveBeenCalledWith(new OpenSidebar());
});
});

describe('setVisibility', () => {
it('should call store.dispatch with a SetSidebarAction action', () => {
component.setVisibility(true);

expect(store.dispatch).toHaveBeenCalledWith(new SetSidebarState({ open: true }));
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import {
Store,
select,
} from '@ngrx/store';
import { DaffioDoc } from 'apps/daffio/src/app/docs/models/doc';
import { DaffioDocsService } from 'apps/daffio/src/app/docs/services/docs.service';
import {
map,
Observable,
Expand All @@ -17,13 +15,8 @@ import {
import { DaffSidebarMode } from '@daffodil/design/sidebar';
import { DaffRouterNamedViewService } from '@daffodil/router';

import { DaffioGuideList } from '../../../../docs/models/guide-list';
import { DaffioRouterNamedViewsEnum } from '../../../../named-views/models/named-views.enum';
import {
CloseSidebar,
OpenSidebar,
SetSidebarState,
} from '../../actions/sidebar.actions';
import { CloseSidebar } from '../../actions/sidebar.actions';
import * as fromDaffioSidebar from '../../reducers/index';

@Component({
Expand All @@ -38,13 +31,11 @@ export class DaffioSidebarViewportContainer implements OnInit {
readonly sidebarFooterNamedView = DaffioRouterNamedViewsEnum.SIDEBARFOOTER;

showSidebar$: Observable<boolean>;
sidebarContents$: Observable<DaffioGuideList>;
mode$: Observable<DaffSidebarMode>;
showSidebarHeader$: Observable<boolean>;
showSidebarFooter$: Observable<boolean>;

ngOnInit() {
this.sidebarContents$ = this.docService.getGuideList();
this.showSidebar$ = this.store.pipe(select(fromDaffioSidebar.selectShowSidebar));
this.mode$ = this.store.pipe(select(fromDaffioSidebar.selectSidebarMode));
this.showSidebarHeader$ = this.namedViewService.namedViews$.pipe(map((namedViews) => !!namedViews[this.sidebarHeaderNamedView]));
Expand All @@ -53,18 +44,9 @@ export class DaffioSidebarViewportContainer implements OnInit {

constructor(
private store: Store<fromDaffioSidebar.State>,
private docService: DaffioDocsService<DaffioDoc, DaffioGuideList>,
private namedViewService: DaffRouterNamedViewService) { }

close() {
this.store.dispatch(new CloseSidebar());
}

open() {
this.store.dispatch(new OpenSidebar());
}

setVisibility(state: boolean) {
this.store.dispatch(new SetSidebarState({ open: state }));
}
}

0 comments on commit 4b5acdd

Please sign in to comment.