Skip to content

Commit

Permalink
Fixed issue with LocaleInterceptor that blocked new request
Browse files Browse the repository at this point in the history
  • Loading branch information
atarix83 committed Sep 3, 2020
1 parent 99c0f6c commit a76e079
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
11 changes: 6 additions & 5 deletions src/app/core/auth/auth.service.ts
Expand Up @@ -21,8 +21,8 @@ import {
getAuthenticationToken,
getRedirectUrl,
isAuthenticated,
isTokenRefreshing,
isAuthenticatedLoaded
isAuthenticatedLoaded,
isTokenRefreshing
} from './selectors';
import { AppState, routerStateSelector } from '../../app.reducer';
import {
Expand All @@ -34,7 +34,7 @@ import { NativeWindowRef, NativeWindowService } from '../services/window.service
import { Base64EncodeUrl } from '../../shared/utils/encode-decode.util';
import { RouteService } from '../services/route.service';
import { EPersonDataService } from '../eperson/eperson-data.service';
import { getAllSucceededRemoteDataPayload } from '../shared/operators';
import { getAllSucceededRemoteDataPayload, getFinishedRemoteData, getRemoteDataPayload } from '../shared/operators';
import { AuthMethod } from './models/auth.method';

export const LOGIN_ROUTE = '/login';
Expand Down Expand Up @@ -206,8 +206,9 @@ export class AuthService {
return this.store.pipe(
select(getAuthenticatedUserId),
hasValueOperator(),
switchMap((id: string) => this.epersonService.findById(id) ),
getAllSucceededRemoteDataPayload()
switchMap((id: string) => this.epersonService.findById(id)),
getFinishedRemoteData(),
getRemoteDataPayload(),
)
}

Expand Down
24 changes: 13 additions & 11 deletions src/app/core/locale/locale.service.ts
@@ -1,14 +1,14 @@
import { Injectable, Inject } from '@angular/core';
import { Inject, Injectable } from '@angular/core';

import { TranslateService } from '@ngx-translate/core';

import { isEmpty, isNotEmpty } from '../../shared/empty.util';
import { CookieService } from '../services/cookie.service';
import { environment } from '../../../environments/environment';
import { AuthService } from '../auth/auth.service';
import { Observable, of as observableOf, combineLatest } from 'rxjs';
import { map, take, flatMap } from 'rxjs/operators';
import { NativeWindowService, NativeWindowRef } from '../services/window.service';
import { combineLatest, Observable, of as observableOf } from 'rxjs';
import { flatMap, map, take } from 'rxjs/operators';
import { NativeWindowRef, NativeWindowService } from '../services/window.service';

export const LANG_COOKIE = 'language_cookie';

Expand All @@ -19,7 +19,7 @@ export enum LANG_ORIGIN {
UI,
EPERSON,
BROWSER
};
}

/**
* Service to provide localization handler
Expand Down Expand Up @@ -81,12 +81,14 @@ export class LocaleService {
take(1),
map((eperson) => {
const languages: string[] = [];
const ePersonLang = eperson.firstMetadataValue(this.EPERSON_LANG_METADATA);
if (ePersonLang) {
languages.push(...this.setQuality(
[ePersonLang],
LANG_ORIGIN.EPERSON,
!isEmpty(this.translate.currentLang)));
if (eperson) {
const ePersonLang = eperson.firstMetadataValue(this.EPERSON_LANG_METADATA);
if (ePersonLang) {
languages.push(...this.setQuality(
[ePersonLang],
LANG_ORIGIN.EPERSON,
!isEmpty(this.translate.currentLang)));
}
}
return languages;
})
Expand Down

0 comments on commit a76e079

Please sign in to comment.