Merge branch 'spencer/update-phone-pointer' into 'master'

Update data associated to phone pointers on phone number change.

See merge request grassrootseconomics/cic-staff-client!43
This commit is contained in:
Spencer Ofwiti 2021-07-26 07:36:11 +00:00
commit 858e1e65bd
2 changed files with 13 additions and 3 deletions

View File

@ -11,7 +11,7 @@ import { MutableKeyStore, PGPSigner, Signer } from '@app/_pgp';
import { RegistryService } from '@app/_services/registry.service';
import { CICRegistry } from '@cicnet/cic-client';
import { personValidation, updateSyncable, vcardValidation } from '@app/_helpers';
import { add0x } from '@src/assets/js/ethtx/dist/hex';
import { add0x, strip0x } from '@src/assets/js/ethtx/dist/hex';
import { KeystoreService } from '@app/_services/keystore.service';
const vCard = require('vcard-parser');
@ -75,7 +75,8 @@ export class UserService {
businessCategory: string,
userLocation: string,
location: string,
locationType: string
locationType: string,
oldPhoneNumber: string
): Promise<any> {
const accountInfo: any = {
vcard: {
@ -142,6 +143,14 @@ export class UserService {
await this.updateMeta(syncableAccount, accountKey, this.headers);
}
);
if (phoneNumber !== oldPhoneNumber) {
const oldPhoneKey: string = await Phone.toKey(oldPhoneNumber);
const newPhoneKey: string = await Phone.toKey(phoneNumber);
const newPhoneData: Syncable = new Syncable(newPhoneKey, strip0x(address));
await this.updateMeta(newPhoneData, newPhoneKey, this.headers);
const oldPhoneData: Syncable = new Syncable(oldPhoneKey, '');
await this.updateMeta(oldPhoneData, oldPhoneKey, this.headers);
}
return accountKey;
}

View File

@ -253,7 +253,8 @@ export class AccountDetailsComponent implements OnInit, AfterViewInit {
this.accountInfoFormStub.businessCategory.value,
this.accountInfoFormStub.userLocation.value,
this.accountInfoFormStub.location.value,
this.accountInfoFormStub.locationType.value
this.accountInfoFormStub.locationType.value,
this.account.vcard?.tel[0].value
);
this.submitted = false;
}