Skip to content

Commit

Permalink
Feature/Add check for undefined parentId of shared Attributes (#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
Milena-Czierlinski authored Oct 18, 2024
1 parent b521f4f commit a500474
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,35 @@ export interface ILocalAttribute extends ICoreSynchronizable {
export type OwnSharedIdentityAttribute = LocalAttribute & {
content: IdentityAttribute;
shareInfo: LocalAttributeShareInfo;
parentId: undefined;
isDefault: undefined;
};

export type OwnSharedRelationshipAttribute = LocalAttribute & {
content: RelationshipAttribute;
shareInfo: LocalAttributeShareInfo;
parentId: undefined;
isDefault: undefined;
};

export type PeerSharedIdentityAttribute = LocalAttribute & {
content: IdentityAttribute;
shareInfo: LocalAttributeShareInfo & { sourceAttribute: undefined };
parentId: undefined;
isDefault: undefined;
};

export type PeerSharedRelationshipAttribute = LocalAttribute & {
content: RelationshipAttribute;
shareInfo: LocalAttributeShareInfo & { sourceAttribute: undefined };
parentId: undefined;
isDefault: undefined;
};

export type ThirdPartyOwnedRelationshipAttribute = LocalAttribute & {
content: RelationshipAttribute;
shareInfo: LocalAttributeShareInfo;
parentId: undefined;
isDefault: undefined;
};

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

isOwnSharedAttribute &&= !this.parentId;
isOwnSharedAttribute &&= !this.isDefault;

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

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

isPeerSharedAttribute &&= !this.parentId;
isPeerSharedAttribute &&= !this.isDefault;

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

isThirdPartyOwnedAttribute &&= !this.parentId;
isThirdPartyOwnedAttribute &&= !this.isDefault;

if (thirdPartyAddress) isThirdPartyOwnedAttribute &&= this.isOwnedBy(thirdPartyAddress);
Expand Down

0 comments on commit a500474

Please sign in to comment.