Fix a bug with community subject changed while getting community Info in landing contexts

This commit is contained in:
Konstantinos Triantafyllou 2021-11-30 18:21:35 +02:00
parent 2eb06717dd
commit 8ad3eff16b
2 changed files with 9 additions and 106 deletions

View File

@ -32,12 +32,16 @@ export class CommunityService {
this.community.next(community);
}
getCommunityInfo(communityId: string) {
return this.http.get<CommunityInfo>(properties.communityAPI + communityId)
.pipe(map(community => this.parseCommunity(community)));
}
getCommunity(communityId: string, refresh = false) {
if (this.communityId !== communityId || !this.community.value || refresh) {
this.communityId = communityId;
this.promise = new Promise<any>((resolve, reject) => {
this.subs.push(this.http.get<CommunityInfo>(properties.communityAPI + communityId)
.pipe(map(community => this.parseCommunity(community))).subscribe(community => {
this.subs.push(this.getCommunityInfo(communityId).subscribe(community => {
this.community.next(community);
resolve();
},

View File

@ -58,104 +58,6 @@ import {HelperFunctions} from "../../utils/HelperFunctions.class";
</div>
</div>
</ng-container>
<!-- <ng-container *ngIf="connectLinksView; else elseBlock"> -->
<!-- One gateway link -->
<!-- <div *ngIf="gateways && gateways.length === 1" class="uk-margin-medium-top uk-width-1-2@m">
<div class="uk-card uk-card-default uk-flex">
<div class="uk-width-2-3@m uk-card-body flex-column">
<img *ngIf="gateways[0].logo" src="{{gateways[0].logo}}" alt="OpenAIRE Gateway logo" class="gateway-link-logo">
<div>
<span class="uk-text-muted">Visit: </span>
<a href="{{gateways[0].link}}" target="_blank">
{{gateways[0].labelContext}}
<span class="custom-external custom-icon space"></span>
</a>
</div>
</div>
<div class="uk-width-1-3@m uk-position-relative">
<img class="uk-position-bottom-right" src="assets/common-assets/connect_image_faded.png" alt="OpenAIRE Connect image">
</div>
</div>
</div> -->
<!-- Two gateway links -->
<!-- <div *ngIf="gateways && gateways.length === 2" class="uk-margin-large-top uk-margin-large-right">
<div class="uk-card uk-card-default uk-flex">
<div class="uk-width-2-3@m uk-card-body uk-flex flex-gap">
<div class="flex-column min-width-30">
<img *ngIf="gateways[0].logo" src="{{gateways[0].logo}}" alt="sOpenAIRE Gateway logo" class="gateway-link-logo">
<div>
<span class="uk-text-muted">Visit: </span>
<a href="{{gateways[0].link}}" target="_blank">
{{gateways[0].labelContext}}
<span class="custom-external custom-icon space"></span>
</a>
</div>
</div>
<div class="verticalLine"></div>
<div class="flex-column min-width-30">
<img *ngIf="gateways[1].logo" src="{{gateways[1].logo}}" alt="OpenAIRE Gateway logo" class="gateway-link-logo">
<div>
<span class="uk-text-muted">Visit: </span>
<a href="{{gateways[1].link}}" target="_blank">
{{gateways[1].labelContext}}
<span class="custom-external custom-icon space"></span>
</a>
</div>
</div>
</div>
<div class="uk-width-1-3@m uk-position-relative">
<img class="uk-position-bottom-right custom-height-130" src="assets/common-assets/connect_image_faded.png" alt="OpenAIRE Connect image">
</div>
</div>
</div> -->
<!-- Three or more gateway links -->
<!-- <div *ngIf="gateways && gateways.length > 2" class="uk-margin-large-top uk-margin-large-right">
<div class="uk-card uk-card-default uk-flex">
<div class="uk-width-expand@m uk-card-body uk-padding-remove-right uk-flex flex-gap">
<div class="list">
<div>
<span class="uk-text-muted">Visit Connect gateways: </span>
</div>
<ul class="custom-list">
<li *ngFor="let gateway of gateways">
<a href="{{gateway.link}}" target="_blank">
{{ gateway.labelContext }}
<span class="custom-external custom-icon space"></span>
</a>
</li>
</ul>
</div>
</div>
<div class="uk-width-small@m uk-position-relative">
<img class="uk-position-bottom-right custom-height-130" src="assets/common-assets/connect_image_faded.png" alt="OpenAIRE Connect image">
</div>
</div>
</div> -->
<!-- </ng-container> -->
<!-- <ng-template #elseBlock>
<div class="uk-text-muted">Communities</div>
<div class="uk-margin-small-left" *ngFor="let item of contexts.slice(0, showNum); let i=index">
<span>
<span>{{item['labelContext']}}</span> -->
<!-- <a *ngIf="item['link']; else noLink" [href]="item['link']" target="_blank">{{item['labelContext']}}</a> -->
<!-- <ng-template #noLink> -->
<!-- </ng-template> -->
<!-- <span *ngIf="item['labelCategory']"><span
uk-icon="icon: arrow-right"></span>{{item['labelCategory']}}</span>
<span *ngIf="item['labelConcept']">: {{item['labelConcept']}}</span>
</span>
</div>
<div *ngIf="showNum > threshold" class="uk-text-right">
<a (click)="showNum = threshold; scroll()">
View less
</a>
</div>
<div *ngIf="showNum == threshold && contexts && contexts.length > threshold" class="uk-text-right">
<a (click)="showNum = contexts.length;">
View more
</a>
</div>
</ng-template> -->
`
})
@ -182,16 +84,13 @@ export class RelatedToComponent implements OnInit {
this.userManagementService.getUserInfo().subscribe( user => {
//- handling subscribe errors?
this.subscriptions.push(
this.communityService.getCommunity(context.idContext).subscribe( community => {
this.communityService.getCommunityInfo(context.idContext).subscribe( community => {
if(community && !ConnectHelper.isPrivate(community,user) && (this.currentCommunity != context.idContext)) {
// creating the link, based on the enviroment
let url = '';
if(properties.environment == "beta") {
url = 'https://beta.' + context.idContext + '.openaire.eu';
context.link = 'https://beta.' + context.idContext + '.openaire.eu';
} else {
url = 'https://' + context.idContext + '.openaire.eu';
context.link = 'https://' + context.idContext + '.openaire.eu';
}
context.link = url;
for(let gateway of this.gateways) {
if(gateway.link == context.link) {
return; // skips so that we don't get duplicate gateways