Fix community logoUrl bug when it is uploaded

This commit is contained in:
Konstantinos Triantafyllou 2021-11-12 12:36:16 +02:00
parent 23f9f2c768
commit 79e6748d7f
4 changed files with 21 additions and 15 deletions

View File

@ -98,6 +98,6 @@ export class CommunitiesService {
communities.push(result);
}
}
return communities;
return CommunityInfo.checkIsUpload(communities);
}
}

View File

@ -55,18 +55,6 @@ export class CommunityService {
return this.community.getValue();
}
private checkIsUpload(response: CommunityInfo | CommunityInfo[]): any | any[] {
if (Array.isArray(response)) {
response.forEach(value => {
value.isUpload = value.logoUrl && !StringUtils.isValidUrl(value.logoUrl);
});
} else {
response.isUpload = response.logoUrl && !StringUtils.isValidUrl(response.logoUrl);
}
return response;
}
updateCommunity(url: string, community: any) {
if (!community.logoUrl) {
community.logoUrl = '';
@ -131,7 +119,7 @@ export class CommunityService {
community.subjects[i] = subject;
}
}
return this.checkIsUpload(community);
return CommunityInfo.checkIsUpload(community);
}
isRIType(community: string): Observable<boolean> {

View File

@ -1,3 +1,6 @@
import {StringUtils} from "../../utils/string-utils.class";
import {properties} from "../../../../environments/environment";
export class CommunityInfo {
title: string;
shortTitle:string;
@ -14,5 +17,20 @@ export class CommunityInfo {
isUpload: boolean;
isSubscribed: boolean;
isManager: boolean;
getLogoUrl() {
return (this.isUpload?(properties.utilsService + '/download/' + this.logoUrl):this.logoUrl);
}
public static checkIsUpload(response: CommunityInfo | CommunityInfo[]): any | any[] {
if (Array.isArray(response)) {
response.forEach(value => {
value.isUpload = value.logoUrl && !StringUtils.isValidUrl(value.logoUrl);
});
} else {
response.isUpload = response.logoUrl && !StringUtils.isValidUrl(response.logoUrl);
}
return response;
}
}
// export const prodReadyCommunities = ["dh-ch", "ee", "fam", "mes", "ni", "covid-19", "dariah", "epos", "egi"];

View File

@ -147,7 +147,7 @@ export class RelatedToComponent implements OnInit {
context.link = url;
// grabbing the logoUrl for the gateway links
if(community.logoUrl) {
context.logo = community.logoUrl;
context.logo = community.getLogoUrl();
}
for(let gateway of this.gateways) {
if(gateway.link == context.link) {