Skip to content

Commit

Permalink
Don't bother fetching separate property tags for properties, closes u…
Browse files Browse the repository at this point in the history
  • Loading branch information
g1eb committed Sep 23, 2021
1 parent f18d0aa commit 3b5277d
Showing 1 changed file with 2 additions and 39 deletions.
41 changes: 2 additions & 39 deletions src/components/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import TableCell from './TableCell'
import OverlayMenu from './OverlayMenu'
import useStyles from '../styles/table'
import * as utils from '../utils/table'
import fetchEntity from '../utils/fetchEntity'
import fetchSuggestions from '../utils/fetchSuggestions'
import uploadAnnotations from '../utils/uploadAnnotations'
import uploadWikinodes from '../utils/uploadWikinodes'
Expand Down Expand Up @@ -154,25 +153,7 @@ const Table = ({
// update project layers
const layers = projectData.layers
if ( !!layers && 'qnode' in layers && 'entries' in layers.qnode ) {

// Check for property qnodes without tags and pre-fetch the tags
const entries = []
const fetchPromises = []
layers.qnode.entries.forEach(entry => {
if ( entry.id[0] === 'P' ) {
fetchPromises.push(
fetchEntity(entry, projectData.filepath, projectData.sheetName)
.then(entity => entries.push({...entry, tags: entity.tags}))
)
} else {
entries.push(entry)
}
})

// Update qnode layers with the augmented entries with tags
Promise.all(fetchPromises).then(() => {
setLayers({qnode: {entries}})
})
setLayers(layers)
}

setTableData(prev => {
Expand Down Expand Up @@ -341,25 +322,7 @@ const Table = ({
'string',
)
.then(layers => {

// Check for property qnodes without tags and pre-fetch the tags
const entries = []
const fetchPromises = []
layers.qnode.entries.forEach(entry => {
if ( entry.id[0] === 'P' ) {
fetchPromises.push(
fetchEntity(entry, projectData.filepath, projectData.sheetName)
.then(entity => entries.push({...entry, tags: entity.tags}))
)
} else {
entries.push(entry)
}
})

// Update qnode layers with the augmented entries with tags
Promise.all(fetchPromises).then(() => {
setLayers({qnode: {entries}})
})
setLayers(layers)

// Show a success message
setMessage({
Expand Down

0 comments on commit 3b5277d

Please sign in to comment.