use methods isPublic, isRestricted, isPrivate instead of using the previous checks and add validateStatus method

This commit is contained in:
argirok 2023-07-19 12:57:28 +03:00
parent 7354d0ad55
commit c8c5e2d925
3 changed files with 7 additions and 8 deletions

View File

@ -58,10 +58,7 @@ export class CommunitiesService {
result['status'] = 'all';
if (resData.hasOwnProperty('status')) {
result['status'] = resData.status;
const status = ['all', 'hidden', 'manager'];
if (status.indexOf(result['status']) === -1) {
result['status'] = 'hidden';
}
result.validateStatus();
}
if (resData.type != null) {
result['type'] = resData.type;

View File

@ -103,10 +103,7 @@ export class CommunityService {
community.otherZenodoCommunities = resData.otherZenodoCommunities;
if (resData.hasOwnProperty('status')) {
community.status = resData.status;
const status = ['all', 'hidden', 'manager'];
if(!( community.isPrivate() || community.isRestricted() || community.isPublic())) {
community.status = 'PRIVATE';
}
community.validateStatus();
}
if (resData.subjects != null) {
community.subjects = Array.isArray(resData.subjects)?resData.subjects:[resData.subjects];

View File

@ -43,5 +43,10 @@ export class CommunityInfo {
public isPrivate(){
return this.status == "hidden" || this.status == "PRIVATE";
}
public validateStatus(){
if(!(this.isPrivate() || this.isRestricted() || this.isPublic())){
this.status = "PRIVATE";
}
}
}
// export const prodReadyCommunities = ["dh-ch", "ee", "fam", "mes", "ni", "covid-19", "dariah", "epos", "egi"];