diff --git a/scilog/src/app/app.component.spec.ts b/scilog/src/app/app.component.spec.ts index 7d448ff9..10f6587f 100644 --- a/scilog/src/app/app.component.spec.ts +++ b/scilog/src/app/app.component.spec.ts @@ -33,16 +33,4 @@ describe('AppComponent', () => { // expect(app.title).toEqual('SciLog'); // }); - it('should unset the logbook', () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - const popStateEvent = new PopStateEvent('popstate'); - Object.defineProperty( - popStateEvent, - 'target', - {writable: false, value: {location: {pathname: '/overview'}}} - ); - window.dispatchEvent(popStateEvent); - expect(app['logbookInfo'].logbookInfo).toBeNull(); - }); }); diff --git a/scilog/src/app/app.component.ts b/scilog/src/app/app.component.ts index 47122e06..36d325e5 100644 --- a/scilog/src/app/app.component.ts +++ b/scilog/src/app/app.component.ts @@ -1,5 +1,4 @@ -import { Component, HostListener, OnInit } from '@angular/core'; -import { LogbookInfoService } from './core/logbook-info.service'; +import { Component, OnInit } from '@angular/core'; @Component({ @@ -12,8 +11,7 @@ export class AppComponent implements OnInit { light_mode = true; disable_log = false; - constructor(private logbookInfo: LogbookInfoService) { - } + constructor() {} ngOnInit(): void { @@ -31,10 +29,4 @@ export class AppComponent implements OnInit { } } - @HostListener('window:popstate', ['$event']) - onPopState(event: Event & {target: Window}) { - if (event.target.location.pathname === '/overview') - this.logbookInfo.logbookInfo = null; - } - } diff --git a/scilog/src/app/logbook/logbook.component.spec.ts b/scilog/src/app/logbook/logbook.component.spec.ts index 7191427a..9fa9b07e 100644 --- a/scilog/src/app/logbook/logbook.component.spec.ts +++ b/scilog/src/app/logbook/logbook.component.spec.ts @@ -30,4 +30,16 @@ describe('LogbookComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + it('should unset the logbook', () => { + const popStateEvent = new PopStateEvent('popstate'); + Object.defineProperty( + popStateEvent, + 'target', + {writable: false, value: {location: {pathname: '/overview'}}} + ); + window.dispatchEvent(popStateEvent); + expect(component['logbookInfo'].logbookInfo).toBeNull(); + }); + }); diff --git a/scilog/src/app/logbook/logbook.component.ts b/scilog/src/app/logbook/logbook.component.ts index 4d2a8258..5328eca1 100644 --- a/scilog/src/app/logbook/logbook.component.ts +++ b/scilog/src/app/logbook/logbook.component.ts @@ -1,7 +1,7 @@ -import { Component, OnInit, ComponentFactoryResolver } from '@angular/core'; +import { Component, OnInit, HostListener } from '@angular/core'; import { ChangeStreamService } from '@shared/change-stream.service'; import { ChangeStreamNotification } from '@shared/changestreamnotification.model' -import { MediaObserver, MediaChange } from '@angular/flex-layout'; +import { MediaObserver } from '@angular/flex-layout'; import { Subscription } from 'rxjs'; import { ActivatedRoute, Router } from '@angular/router'; import { LogbookInfoService } from '@shared/logbook-info.service'; @@ -149,5 +149,10 @@ export class LogbookComponent implements OnInit { (subscription) => subscription.unsubscribe()); } + @HostListener('window:popstate', ['$event']) + onPopState(event: Event & {target: Window}) { + if (event.target.location.pathname === '/overview') + this.logbookInfo.logbookInfo = null; + } }