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

Fix issue regarding link auto deletion on workspace load affecting #393 #419

Merged
merged 2 commits into from
Mar 2, 2022
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
2 changes: 1 addition & 1 deletion src/components/modals/CreationModals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const CreationModals: React.FC<Props> = (props) => {
props.linkConfiguration.targetID,
]
),
updateProjectLink(false, ...initConnections())
updateProjectLink(false, ...initConnections().add)
);
setRepresentation(Representation.COMPACT);
AppSettings.selectedElements = [];
Expand Down
2 changes: 1 addition & 1 deletion src/function/FunctionElem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ export async function putElementsOnCanvas(
);
const newIDs = initElements(true);
queries.push(updateProjectElement(false, ...newIDs));
queries.push(updateProjectLink(false, ...initConnections()));
queries.push(updateProjectLink(false, ...initConnections().add));
ids.push(...newIDs);
addToFlexSearch(...ids);
}
Expand Down
2 changes: 1 addition & 1 deletion src/function/FunctionGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export async function spreadConnections(
);
const newIDs = initElements();
queries.push(updateProjectElement(false, ...newIDs));
queries.push(updateProjectLink(false, ...initConnections()));
queries.push(updateProjectLink(false, ...initConnections().add));
ids.push(...newIDs);
}
const elem = graph.getElements().find((elem) => elem.id === id);
Expand Down
5 changes: 2 additions & 3 deletions src/function/FunctionRestriction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function createRestriction(
restrictions.push(restriction);
}

export function initConnections(removeOutdated: boolean = false): string[] {
export function initConnections(): { add: string[]; del: string[] } {
const linksToPush = [];
const linksToDelete: string[] = Object.keys(WorkspaceLinks);
const restrictions = _.flatten(
Expand Down Expand Up @@ -99,6 +99,5 @@ export function initConnections(removeOutdated: boolean = false): string[] {
}
}
}
if (removeOutdated) return linksToPush.concat(linksToDelete);
return linksToPush;
return { add: linksToPush, del: linksToDelete };
}
14 changes: 4 additions & 10 deletions src/interface/ContextInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,8 @@ export async function retrieveContextData(): Promise<boolean> {
)
return false;
addToFlexSearch(...Object.keys(WorkspaceElements));
const connections = initConnections(true);
const connectionsToDelete = connections.filter(
(link) => link in WorkspaceLinks
);
const connectionsToInitialize = connections.filter(
(link) => !(link in WorkspaceLinks)
);
for (const id of connectionsToDelete) {
const connections = initConnections();
for (const id of connections.del) {
// This is expected behaviour e.g. for imported diagrams,
// if they have references to links that no longer exist in the data.
console.warn(
Expand All @@ -238,8 +232,8 @@ export async function retrieveContextData(): Promise<boolean> {
return await processTransaction(
AppSettings.contextEndpoint,
qb.constructQuery(
updateProjectLink(false, ...connectionsToInitialize),
updateDeleteProjectLink(true, ...connectionsToDelete)
updateProjectLink(false, ...connections.add),
updateDeleteProjectLink(true, ...connections.del)
)
);
}
2 changes: 1 addition & 1 deletion src/queries/update/UpdateReconstructAppContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function reconstructApplicationContextWithDiagrams(): Promise<strin
.then((data) => {
const result = [];
for (const diag of data.results.bindings) {
result.push(diag.diagram.value);
result.push(diag.graph.value);
}
return result;
})
Expand Down