From 8ad3eff16b952d1afe0f425f7c4ebd6c26579c64 Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Tue, 30 Nov 2021 18:21:35 +0200 Subject: [PATCH] Fix a bug with community subject changed while getting community Info in landing contexts --- connect/community/community.service.ts | 8 +- .../landing-utils/relatedTo.component.ts | 107 +----------------- 2 files changed, 9 insertions(+), 106 deletions(-) diff --git a/connect/community/community.service.ts b/connect/community/community.service.ts index e7034de1..3d328f2f 100644 --- a/connect/community/community.service.ts +++ b/connect/community/community.service.ts @@ -32,12 +32,16 @@ export class CommunityService { this.community.next(community); } + getCommunityInfo(communityId: string) { + return this.http.get(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((resolve, reject) => { - this.subs.push(this.http.get(properties.communityAPI + communityId) - .pipe(map(community => this.parseCommunity(community))).subscribe(community => { + this.subs.push(this.getCommunityInfo(communityId).subscribe(community => { this.community.next(community); resolve(); }, diff --git a/landingPages/landing-utils/relatedTo.component.ts b/landingPages/landing-utils/relatedTo.component.ts index 974b191e..fa9245db 100644 --- a/landingPages/landing-utils/relatedTo.component.ts +++ b/landingPages/landing-utils/relatedTo.component.ts @@ -58,104 +58,6 @@ import {HelperFunctions} from "../../utils/HelperFunctions.class"; - - - - - - - - - - - - - ` }) @@ -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