From 4cf4c8d0400f01f7b57ec0fc3e1e0a81da91bded Mon Sep 17 00:00:00 2001 From: HuyNguyen Date: Tue, 21 Jan 2025 00:31:17 +0700 Subject: [PATCH] [SYNC-CONTACT-V2] Update contact model --- .../{contact_v2.dart => contact_new.dart} | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) rename lib/domain/model/contact/{contact_v2.dart => contact_new.dart} (86%) diff --git a/lib/domain/model/contact/contact_v2.dart b/lib/domain/model/contact/contact_new.dart similarity index 86% rename from lib/domain/model/contact/contact_v2.dart rename to lib/domain/model/contact/contact_new.dart index 5975d5f47..8d59096d5 100644 --- a/lib/domain/model/contact/contact_v2.dart +++ b/lib/domain/model/contact/contact_new.dart @@ -69,13 +69,14 @@ abstract class ThirdPartyContact with EquatableMixin { final ThirdPartyStatus? status; - final Map> _thirdPartyIdToHashMap = {}; + final Map>? thirdPartyIdToHashMap; ThirdPartyContact({ required this.thirdPartyId, required this.thirdPartyIdType, this.matrixId, this.status, + this.thirdPartyIdToHashMap, }); String calculateHashWithAlgorithmSha256({ @@ -124,20 +125,13 @@ abstract class ThirdPartyContact with EquatableMixin { return hashes; } - void setThirdPartyIdToHashMap(List hashes) { - _thirdPartyIdToHashMap[thirdPartyId] = hashes; - } - - Map> getThirdPartyIdToHashMap() { - return _thirdPartyIdToHashMap; - } - @override List get props => [ thirdPartyId, thirdPartyIdType, matrixId, status, + thirdPartyIdToHashMap, ]; } @@ -148,6 +142,7 @@ class PhoneNumber extends ThirdPartyContact { required this.number, super.matrixId, super.status, + super.thirdPartyIdToHashMap, }) : super( thirdPartyId: number.msisdnSanitizer(), thirdPartyIdType: ThirdPartyIdType.msisdn, @@ -158,16 +153,22 @@ class PhoneNumber extends ThirdPartyContact { number, matrixId, status, + thirdPartyIdToHashMap, + thirdPartyId, + thirdPartyIdType, ]; PhoneNumber copyWith({ String? matrixId, ThirdPartyStatus? status, + Map>? thirdPartyIdToHashMap, }) { return PhoneNumber( number: number, matrixId: matrixId ?? this.matrixId, status: status ?? this.status, + thirdPartyIdToHashMap: + thirdPartyIdToHashMap ?? this.thirdPartyIdToHashMap, ); } } @@ -179,6 +180,7 @@ class Email extends ThirdPartyContact { required this.address, super.matrixId, super.status, + super.thirdPartyIdToHashMap, }) : super( thirdPartyId: address, thirdPartyIdType: ThirdPartyIdType.email, @@ -187,11 +189,14 @@ class Email extends ThirdPartyContact { Email copyWith({ String? matrixId, ThirdPartyStatus? status, + Map>? thirdPartyIdToHashMap, }) { return Email( address: address, matrixId: matrixId ?? this.matrixId, status: status ?? this.status, + thirdPartyIdToHashMap: + thirdPartyIdToHashMap ?? this.thirdPartyIdToHashMap, ); } @@ -200,5 +205,8 @@ class Email extends ThirdPartyContact { address, matrixId, status, + thirdPartyIdToHashMap, + thirdPartyId, + thirdPartyIdType, ]; }