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

Fixes for deletion-detect algorithm #16

Merged
merged 10 commits into from
Dec 17, 2021
Merged
Show file tree
Hide file tree
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
30 changes: 20 additions & 10 deletions core/src/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export class SubjectNode extends Node implements SubjectNodeProps {
result.comment = `Inserted a new subject - ${this.key}`;
}

this.pc.subjectCache[this.key] = result.entityId;
this.pc.onSyncSubject(result, this);
return result;
}

Expand Down Expand Up @@ -298,7 +298,7 @@ export class ModelNode extends Node implements ModelNodeProps {
result.comment = `Inserted a new Model - ${this.key}`;
}

this.pc.modelCache[this.key] = result.entityId;
this.pc.onSyncModel(result, this);
return result;
}

Expand Down Expand Up @@ -356,21 +356,31 @@ export class LoaderNode extends Node implements LoaderNodeProps {
pkey: "nodeKey",
entityKey: "DocumentWithBeGuid",
version: this.loader.version,
data: { nodeKey: this.key, mtimeMs: stats.mtimeMs.toString(), ...this.loader.toJSON() },
data: {
nodeKey: this.key,
mtimeMs: stats.mtimeMs.toString(),
connection: con,
...this.loader.toJSON(),
},
});
break;
case "pcf_api_connection":
instance = new IRInstance({
pkey: "nodeKey",
entityKey: "DocumentWithBeGuid",
version: this.loader.version,
data: { nodeKey: this.key, ...this.loader.toJSON() },
data: {
nodeKey: this.key,
connection: con,
...this.loader.toJSON(),
},
});
break;
}

const modelId = this.pc.modelCache[this.model.key];
const code = RepositoryLink.createCode(this.pc.db, modelId, this.key);

const loaderProps = this.loader.toJSON();
const repoLinkProps = {
classFullName: RepositoryLink.classFullName,
Expand All @@ -390,8 +400,7 @@ export class LoaderNode extends Node implements LoaderNodeProps {
identifier: code.value,
});

this.pc.elementCache[instance.key] = result.entityId;
this.pc.seenIdSet.add(result.entityId);
this.pc.onSyncElement(result, instance);
return result;
}

Expand Down Expand Up @@ -485,8 +494,7 @@ export class ElementNode extends Node implements ElementNodeProps {
});

results.push(result);
this.pc.elementCache[instance.key] = result.entityId;
this.pc.seenIdSet.add(result.entityId);
this.pc.onSyncElement(result, instance);

// Add custom handlers (WIP)
// const classRef = bk.ClassRegistry.getClass(props.classFullName, this.pc.db);
Expand Down Expand Up @@ -552,6 +560,9 @@ export class ElementAspectNode extends Node implements ElementAspectNodeProps {

if (typeof this.dmo.modifyProps === "function")
await this.dmo.modifyProps(this.pc, props, instance);

if (!props.element || !props.element.id)
throw new Error("You must attach \"props.element = { ... } as RelatedElementProps\" in ElementAspectDMO.modifyProps()");

const result = this.pc.syncElementUniqueAspect({
props: props,
Expand All @@ -563,8 +574,7 @@ export class ElementAspectNode extends Node implements ElementAspectNodeProps {
});

results.push(result);
this.pc.aspectCache[instance.key] = result.entityId;
this.pc.seenIdSet.add(result.entityId);
this.pc.onSyncAspect(result, instance);
}
return results;
}
Expand Down
Loading