mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 23:43:01 +00:00
[DURACOM-191] Refactoring in order to remove nested subscriptions
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
BehaviorSubject,
|
BehaviorSubject,
|
||||||
combineLatest,
|
combineLatest,
|
||||||
|
EMPTY,
|
||||||
Observable,
|
Observable,
|
||||||
of,
|
of,
|
||||||
} from 'rxjs';
|
} from 'rxjs';
|
||||||
@@ -15,6 +16,7 @@ import {
|
|||||||
map,
|
map,
|
||||||
switchMap,
|
switchMap,
|
||||||
take,
|
take,
|
||||||
|
tap,
|
||||||
} from 'rxjs/operators';
|
} from 'rxjs/operators';
|
||||||
|
|
||||||
import { isNotEmpty } from '../../shared/empty.util';
|
import { isNotEmpty } from '../../shared/empty.util';
|
||||||
@@ -84,14 +86,12 @@ export class GoogleRecaptchaService {
|
|||||||
return res.hasSucceeded && res.payload && isNotEmpty(res.payload.values) && res.payload.values[0].toLowerCase() === 'true';
|
return res.hasSucceeded && res.payload && isNotEmpty(res.payload.values) && res.payload.values[0].toLowerCase() === 'true';
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
registrationVerification$.subscribe(registrationVerification => {
|
registrationVerification$.pipe(
|
||||||
if (registrationVerification) {
|
switchMap((registrationVerification: boolean) => registrationVerification ? this.loadRecaptchaProperties() : EMPTY),
|
||||||
this.loadRecaptchaProperties();
|
).subscribe();
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadRecaptchaProperties() {
|
loadRecaptchaProperties(): Observable<any> {
|
||||||
const recaptchaKeyRD$ = this.configService.findByPropertyName('google.recaptcha.key.site').pipe(
|
const recaptchaKeyRD$ = this.configService.findByPropertyName('google.recaptcha.key.site').pipe(
|
||||||
getFirstCompletedRemoteData(),
|
getFirstCompletedRemoteData(),
|
||||||
);
|
);
|
||||||
@@ -101,7 +101,8 @@ export class GoogleRecaptchaService {
|
|||||||
const recaptchaModeRD$ = this.configService.findByPropertyName('google.recaptcha.mode').pipe(
|
const recaptchaModeRD$ = this.configService.findByPropertyName('google.recaptcha.mode').pipe(
|
||||||
getFirstCompletedRemoteData(),
|
getFirstCompletedRemoteData(),
|
||||||
);
|
);
|
||||||
combineLatest([recaptchaVersionRD$, recaptchaModeRD$, recaptchaKeyRD$]).subscribe(([recaptchaVersionRD, recaptchaModeRD, recaptchaKeyRD]) => {
|
return combineLatest([recaptchaVersionRD$, recaptchaModeRD$, recaptchaKeyRD$]).pipe(
|
||||||
|
tap(([recaptchaVersionRD, recaptchaModeRD, recaptchaKeyRD]) => {
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.cookieService.get('klaro-anonymous') && this.cookieService.get('klaro-anonymous')[CAPTCHA_NAME] &&
|
this.cookieService.get('klaro-anonymous') && this.cookieService.get('klaro-anonymous')[CAPTCHA_NAME] &&
|
||||||
@@ -134,7 +135,8 @@ export class GoogleRecaptchaService {
|
|||||||
this.loadScript(captchaUrl);
|
this.loadScript(captchaUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -188,7 +190,7 @@ export class GoogleRecaptchaService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
refreshCaptchaScript = () => {
|
refreshCaptchaScript = () => {
|
||||||
this.loadRecaptchaProperties();
|
this.loadRecaptchaProperties().subscribe();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user