RED-4070: Save router history in local storage
This commit is contained in:
parent
d267880f1d
commit
3056ccc19f
@ -2,16 +2,19 @@ import { Injectable } from '@angular/core';
|
||||
import { NavigationEnd, Router } from '@angular/router';
|
||||
import { filter } from 'rxjs/operators';
|
||||
|
||||
const LAST_DOSSIERS_SCREEN = 'routerHistory_lastDossiersScreen';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class RouterHistoryService {
|
||||
private _lastDossiersScreen = '/';
|
||||
private _lastDossiersScreen = localStorage.getItem(LAST_DOSSIERS_SCREEN);
|
||||
|
||||
constructor(private readonly _router: Router) {
|
||||
this._router.events.pipe(filter(event => event instanceof NavigationEnd)).subscribe((event: NavigationEnd) => {
|
||||
if (event.url.includes('/dossiers') || event.url.includes('/archive')) {
|
||||
this._lastDossiersScreen = event.url;
|
||||
localStorage.setItem(LAST_DOSSIERS_SCREEN, this._lastDossiersScreen);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user