Skip to content

Commit a500474

Browse files
Feature/Add check for undefined parentId of shared Attributes (#302)
1 parent b521f4f commit a500474

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/consumption/src/modules/attributes/local/LocalAttribute.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,35 @@ export interface ILocalAttribute extends ICoreSynchronizable {
4141
export type OwnSharedIdentityAttribute = LocalAttribute & {
4242
content: IdentityAttribute;
4343
shareInfo: LocalAttributeShareInfo;
44+
parentId: undefined;
4445
isDefault: undefined;
4546
};
4647

4748
export type OwnSharedRelationshipAttribute = LocalAttribute & {
4849
content: RelationshipAttribute;
4950
shareInfo: LocalAttributeShareInfo;
51+
parentId: undefined;
5052
isDefault: undefined;
5153
};
5254

5355
export type PeerSharedIdentityAttribute = LocalAttribute & {
5456
content: IdentityAttribute;
5557
shareInfo: LocalAttributeShareInfo & { sourceAttribute: undefined };
58+
parentId: undefined;
5659
isDefault: undefined;
5760
};
5861

5962
export type PeerSharedRelationshipAttribute = LocalAttribute & {
6063
content: RelationshipAttribute;
6164
shareInfo: LocalAttributeShareInfo & { sourceAttribute: undefined };
65+
parentId: undefined;
6266
isDefault: undefined;
6367
};
6468

6569
export type ThirdPartyOwnedRelationshipAttribute = LocalAttribute & {
6670
content: RelationshipAttribute;
6771
shareInfo: LocalAttributeShareInfo;
72+
parentId: undefined;
6873
isDefault: undefined;
6974
};
7075

@@ -149,6 +154,7 @@ export class LocalAttribute extends CoreSynchronizable implements ILocalAttribut
149154
public isOwnSharedAttribute(ownAddress: CoreAddress, peerAddress?: CoreAddress): this is OwnSharedIdentityAttribute | OwnSharedRelationshipAttribute {
150155
let isOwnSharedAttribute = this.isShared() && this.isOwnedBy(ownAddress);
151156

157+
isOwnSharedAttribute &&= !this.parentId;
152158
isOwnSharedAttribute &&= !this.isDefault;
153159

154160
if (peerAddress) isOwnSharedAttribute &&= this.shareInfo!.peer.equals(peerAddress);
@@ -160,6 +166,7 @@ export class LocalAttribute extends CoreSynchronizable implements ILocalAttribut
160166

161167
isPeerSharedAttribute &&= !this.shareInfo!.sourceAttribute;
162168

169+
isPeerSharedAttribute &&= !this.parentId;
163170
isPeerSharedAttribute &&= !this.isDefault;
164171

165172
if (peerAddress) isPeerSharedAttribute &&= this.isOwnedBy(peerAddress);
@@ -169,6 +176,7 @@ export class LocalAttribute extends CoreSynchronizable implements ILocalAttribut
169176
public isThirdPartyOwnedAttribute(ownAddress: CoreAddress, thirdPartyAddress?: CoreAddress): this is ThirdPartyOwnedRelationshipAttribute {
170177
let isThirdPartyOwnedAttribute = this.isShared() && !this.isOwnedBy(ownAddress) && !this.isOwnedBy(this.shareInfo.peer);
171178

179+
isThirdPartyOwnedAttribute &&= !this.parentId;
172180
isThirdPartyOwnedAttribute &&= !this.isDefault;
173181

174182
if (thirdPartyAddress) isThirdPartyOwnedAttribute &&= this.isOwnedBy(thirdPartyAddress);

0 commit comments

Comments
 (0)