diff --git a/src/app/_services/user.service.ts b/src/app/_services/user.service.ts index f8f258f..5002026 100644 --- a/src/app/_services/user.service.ts +++ b/src/app/_services/user.service.ts @@ -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 { 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; } diff --git a/src/app/pages/accounts/account-details/account-details.component.ts b/src/app/pages/accounts/account-details/account-details.component.ts index 7a9f1cd..5a7ee16 100644 --- a/src/app/pages/accounts/account-details/account-details.component.ts +++ b/src/app/pages/accounts/account-details/account-details.component.ts @@ -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; }