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

feat: add try catch, additional check for incorrect links #2233

Merged
merged 1 commit into from
Sep 25, 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
28 changes: 26 additions & 2 deletions src/stores/useGraphStore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,31 @@
nodes.push(...structuredNodes)
links.push(...structuredLinks)

simulation.nodes(nodes).force('link').links(links)
try {
simulation.nodes(nodes)

const filteredLinks = links.filter((link: Link<NodeExtended | string>) => {
const { target, source } = link
const simulationNodes = simulation.nodes()

// Log the target and source ref_id for debugging
const targetRefId = (target as NodeExtended)?.ref_id || target
const sourceRefId = (source as NodeExtended)?.ref_id || source

return (
simulationNodes.some((n: NodeExtended) => n.ref_id === targetRefId) &&
simulationNodes.some((n: NodeExtended) => n.ref_id === sourceRefId)
)
})

simulation.force('link').links([]).links(filteredLinks)

simulationHelpers.simulationRestart()
} catch (error) {
console.log(error)

Check warning on line 206 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / craco-build-run

Unexpected console statement

Check warning on line 206 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/admin/topics.cy.ts)

Unexpected console statement

Check warning on line 206 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/curationTable/curation.cy.ts)

Unexpected console statement

Check warning on line 206 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/trendingTopics/trendingTopics.cy.ts)

Unexpected console statement

Check warning on line 206 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/graph/searchAndRender.cy.ts)

Unexpected console statement

Check warning on line 206 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/sentimentChart/sentimentChart.cy.ts)

Unexpected console statement

Check warning on line 206 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/sentimentChart/sentimentAnalysis.cy.ts)

Unexpected console statement

Check warning on line 206 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addContent/addSource.cy.ts)

Unexpected console statement

Check warning on line 206 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/graph/initialRender.cy.ts)

Unexpected console statement

Check warning on line 206 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/seeLatest/latest.cy.ts)

Unexpected console statement

Check warning on line 206 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addNode/addNode.cy.ts)

Unexpected console statement

Check warning on line 206 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/sanity.cy.ts)

Unexpected console statement

Check warning on line 206 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addContent/addYoutube.cy.ts)

Unexpected console statement

Check warning on line 206 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/checkEnv.cy.ts)

Unexpected console statement

Check warning on line 206 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addContent/addTweet.cy.ts)

Unexpected console statement

Check warning on line 206 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addContent/addWebpage.cy.ts)

Unexpected console statement

Check warning on line 206 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/sourcesTable/sourcesTable.cy.ts)

Unexpected console statement

Check warning on line 206 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addNode/addNodeType.cy.ts)

Unexpected console statement

Check warning on line 206 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/admin/signin.cy.ts)

Unexpected console statement
// eslint-disable-next-line no-debugger
}

simulationHelpers.simulationRestart()
// Add simulation node to reference (so that we can access reference on tick to update position)
},

Expand Down Expand Up @@ -272,7 +294,7 @@
simulationRestart: () => {
const { simulation } = get()

if (false) {

Check warning on line 297 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / craco-build-run

Unexpected constant condition

Check warning on line 297 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/admin/topics.cy.ts)

Unexpected constant condition

Check warning on line 297 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/curationTable/curation.cy.ts)

Unexpected constant condition

Check warning on line 297 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/trendingTopics/trendingTopics.cy.ts)

Unexpected constant condition

Check warning on line 297 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/graph/searchAndRender.cy.ts)

Unexpected constant condition

Check warning on line 297 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/sentimentChart/sentimentChart.cy.ts)

Unexpected constant condition

Check warning on line 297 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/sentimentChart/sentimentAnalysis.cy.ts)

Unexpected constant condition

Check warning on line 297 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addContent/addSource.cy.ts)

Unexpected constant condition

Check warning on line 297 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/graph/initialRender.cy.ts)

Unexpected constant condition

Check warning on line 297 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/seeLatest/latest.cy.ts)

Unexpected constant condition

Check warning on line 297 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addNode/addNode.cy.ts)

Unexpected constant condition

Check warning on line 297 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/sanity.cy.ts)

Unexpected constant condition

Check warning on line 297 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addContent/addYoutube.cy.ts)

Unexpected constant condition

Check warning on line 297 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/checkEnv.cy.ts)

Unexpected constant condition

Check warning on line 297 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addContent/addTweet.cy.ts)

Unexpected constant condition

Check warning on line 297 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addContent/addWebpage.cy.ts)

Unexpected constant condition

Check warning on line 297 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/sourcesTable/sourcesTable.cy.ts)

Unexpected constant condition

Check warning on line 297 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addNode/addNodeType.cy.ts)

Unexpected constant condition

Check warning on line 297 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/admin/signin.cy.ts)

Unexpected constant condition
runSimulationPhase(simulation)
}

Expand All @@ -280,6 +302,8 @@
},
},
simulationCreate: (nodes, links) => {
console.log('created')

Check warning on line 305 in src/stores/useGraphStore/index.ts

View workflow job for this annotation

GitHub Actions / craco-build-run

Unexpected console statement

const structuredNodes = structuredClone(nodes)
const structuredLinks = structuredClone(links)

Expand Down
Loading