Add checks for undefined values before saving metadata to meta server.

This commit is contained in:
Spencer Ofwiti 2021-06-18 19:37:12 +03:00
parent 28f87d7ff9
commit 665b28a8ba
2 changed files with 32 additions and 12 deletions

View File

@ -90,17 +90,37 @@ export class UserService {
}, },
location: {}, location: {},
}; };
accountInfo.vcard.fn[0].value = name; if (name) {
accountInfo.vcard.n[0].value = name.split(' '); accountInfo.vcard.fn[0].value = name;
accountInfo.vcard.tel[0].value = phoneNumber; accountInfo.vcard.n[0].value = name.split(' ');
accountInfo.products = [bio]; }
accountInfo.gender = gender; if (phoneNumber) {
accountInfo.age = age; accountInfo.vcard.tel[0].value = phoneNumber;
accountInfo.type = type; }
accountInfo.category = businessCategory; if (bio) {
accountInfo.location.area = location; accountInfo.products = [bio];
accountInfo.location.area_name = userLocation; }
accountInfo.location.area_type = locationType; if (gender) {
accountInfo.gender = gender;
}
if (age) {
accountInfo.age = age;
}
if (type) {
accountInfo.type = type;
}
if (businessCategory) {
accountInfo.category = businessCategory;
}
if (location) {
accountInfo.location.area = location;
}
if (userLocation) {
accountInfo.location.area_name = userLocation;
}
if (locationType) {
accountInfo.location.area_type = locationType;
}
await vcardValidation(accountInfo.vcard); await vcardValidation(accountInfo.vcard);
accountInfo.vcard = btoa(vCard.generate(accountInfo.vcard)); accountInfo.vcard = btoa(vCard.generate(accountInfo.vcard));
const accountKey: string = await User.toKey(address); const accountKey: string = await User.toKey(address);

View File

@ -94,7 +94,7 @@ export class AccountDetailsComponent implements OnInit {
firstName: ['', Validators.required], firstName: ['', Validators.required],
lastName: ['', Validators.required], lastName: ['', Validators.required],
phoneNumber: ['', Validators.required], phoneNumber: ['', Validators.required],
age: ['', Validators.required], age: [''],
type: ['', Validators.required], type: ['', Validators.required],
bio: ['', Validators.required], bio: ['', Validators.required],
gender: ['', Validators.required], gender: ['', Validators.required],