Skip to content

Commit

Permalink
fix: redirect to connect
Browse files Browse the repository at this point in the history
  • Loading branch information
69pmb committed Nov 2, 2023
1 parent 6d2de0b commit 1aadbc6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
13 changes: 4 additions & 9 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import {filter} from 'rxjs/operators';
import {Router, NavigationStart} from '@angular/router';
import {Component, OnInit} from '@angular/core';
import {TranslateService} from '@ngx-translate/core';

Expand All @@ -17,7 +15,6 @@ import {MenuService} from './service/menu.service';
})
export class AppComponent implements OnInit {
constructor(
private router: Router,
private tabsService: TabsService,
private auth: AuthService,
private myDatasService: MyDatasService<Data>,
Expand All @@ -27,12 +24,10 @@ export class AppComponent implements OnInit {
) {}

ngOnInit(): void {
this.router.events
.pipe(filter(event => event instanceof NavigationStart))
.subscribe((event: NavigationStart) => {
this.tabsService.onNavigation(event);
});
this.menuService.event$.subscribe(() => window.scrollTo(0, 0));
this.menuService.event$.subscribe(event => {
this.tabsService.onNavigation(event);
window.scrollTo(0, 0);
});
this.auth.getCurrentUser().subscribe(user => {
if (user) {
this.myDatasService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ <h2>{{ 'login.connect.title' | translate }}:</h2>
{{ 'login.connect.log_in' | translate }}
</button>
<button
type="button"
class="btn btn-outline-primary"
(click)="cancel()"
*ngIf="cancel$ | async"
Expand Down
2 changes: 1 addition & 1 deletion src/app/service/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class AuthService {
if (!user || !user.id) {
user = AuthService.decodeToken();
if (!user || !user.id) {
this.logout();
return undefined;
}
}
return user;
Expand Down
4 changes: 2 additions & 2 deletions src/app/service/tabs.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {BehaviorSubject} from 'rxjs';
import {Injectable} from '@angular/core';
import {Router, NavigationStart} from '@angular/router';
import {Router, NavigationEnd} from '@angular/router';

import {Link} from '../model/model';

Expand Down Expand Up @@ -28,7 +28,7 @@ export class TabsService {
localStorage.setItem('active', JSON.stringify(this.activeLink));
}

onNavigation(event: NavigationStart): void {
onNavigation(event: NavigationEnd): void {
if (!event.url.includes('/login/connect')) {
this.liens[this.liens.map(l => l.url).indexOf(this.activeLink.url)].url =
event.url;
Expand Down

0 comments on commit 1aadbc6

Please sign in to comment.