mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 07:13:32 +00:00
Apply Prettier (#2238)
This commit is contained in:
@@ -1,53 +1,50 @@
|
||||
import {
|
||||
Injectable,
|
||||
OnDestroy
|
||||
} from '@angular/core';
|
||||
import {
|
||||
CanActivate,
|
||||
NavigationEnd,
|
||||
NavigationStart,
|
||||
Router,
|
||||
} from '@angular/router';
|
||||
import { Injectable, OnDestroy } from "@angular/core";
|
||||
import { CanActivate, NavigationEnd, NavigationStart, Router } from "@angular/router";
|
||||
|
||||
import { Subscription } from 'rxjs';
|
||||
import {
|
||||
filter,
|
||||
pairwise,
|
||||
} from 'rxjs/operators';
|
||||
import { Subscription } from "rxjs";
|
||||
import { filter, pairwise } from "rxjs/operators";
|
||||
|
||||
@Injectable()
|
||||
export class DebounceNavigationService implements CanActivate, OnDestroy {
|
||||
navigationStartSub: Subscription;
|
||||
navigationSuccessSub: Subscription;
|
||||
navigationStartSub: Subscription;
|
||||
navigationSuccessSub: Subscription;
|
||||
|
||||
private lastNavigation: NavigationStart;
|
||||
private thisNavigation: NavigationStart;
|
||||
private lastNavigationSuccessId: number;
|
||||
private lastNavigation: NavigationStart;
|
||||
private thisNavigation: NavigationStart;
|
||||
private lastNavigationSuccessId: number;
|
||||
|
||||
constructor(private router: Router) {
|
||||
this.navigationStartSub = this.router.events
|
||||
.pipe(filter(event => event instanceof NavigationStart), pairwise())
|
||||
.subscribe((events: [NavigationStart, NavigationStart]) => [this.lastNavigation, this.thisNavigation] = events);
|
||||
constructor(private router: Router) {
|
||||
this.navigationStartSub = this.router.events
|
||||
.pipe(
|
||||
filter((event) => event instanceof NavigationStart),
|
||||
pairwise()
|
||||
)
|
||||
.subscribe(
|
||||
(events: [NavigationStart, NavigationStart]) =>
|
||||
([this.lastNavigation, this.thisNavigation] = events)
|
||||
);
|
||||
|
||||
this.navigationSuccessSub = this.router.events
|
||||
.pipe(filter(event => event instanceof NavigationEnd))
|
||||
.subscribe((event: NavigationEnd) => this.lastNavigationSuccessId = event.id);
|
||||
this.navigationSuccessSub = this.router.events
|
||||
.pipe(filter((event) => event instanceof NavigationEnd))
|
||||
.subscribe((event: NavigationEnd) => (this.lastNavigationSuccessId = event.id));
|
||||
}
|
||||
|
||||
async canActivate() {
|
||||
return !(
|
||||
this.thisNavigation?.navigationTrigger === "hashchange" &&
|
||||
this.lastNavigation.navigationTrigger === "popstate" &&
|
||||
this.lastNavigationSuccessId === this.lastNavigation.id &&
|
||||
this.lastNavigation.url === this.thisNavigation?.url
|
||||
);
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.navigationStartSub != null) {
|
||||
this.navigationStartSub.unsubscribe();
|
||||
}
|
||||
|
||||
async canActivate() {
|
||||
return !(this.thisNavigation?.navigationTrigger === 'hashchange' &&
|
||||
this.lastNavigation.navigationTrigger === 'popstate' &&
|
||||
this.lastNavigationSuccessId === this.lastNavigation.id &&
|
||||
this.lastNavigation.url === this.thisNavigation?.url);
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.navigationStartSub != null) {
|
||||
this.navigationStartSub.unsubscribe();
|
||||
}
|
||||
|
||||
if (this.navigationSuccessSub != null) {
|
||||
this.navigationSuccessSub.unsubscribe();
|
||||
}
|
||||
if (this.navigationSuccessSub != null) {
|
||||
this.navigationSuccessSub.unsubscribe();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user