Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check for undefined parentId of shared Attributes #302

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading