Skip to content

Commit

Permalink
Consolidate Diff fn
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Aug 8, 2024
1 parent 0807ae8 commit 1722e5b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
27 changes: 0 additions & 27 deletions api/web/src/components/CloudTAK/Map.vue
Original file line number Diff line number Diff line change
Expand Up @@ -837,33 +837,6 @@ export default {
try {
const diff = cotStore.diff();
for (const cot of cotStore.pending.values()) {
const render = cot.as_rendered();
if (cotStore.cots.has(cot.id)) {
diff.update.push({
id: render.id,
addOrUpdateProperties: Object.keys(render.properties).map((key) => {
return { key, value: render.properties[key] }
}),
newGeometry: render.geometry
})
} else {
diff.add.push(render);
}
cotStore.cots.set(cot.id, cot);
}
cotStore.pending.clear();
for (const id of cotStore.pendingDelete) {
diff.remove.push(id);
cotStore.cots.delete(id);
}
cotStore.pendingDelete.clear();
if (diff.add.length || diff.remove.length || diff.update.length) {
mapStore.map.getSource('-1').updateData(diff);
}
Expand Down
27 changes: 27 additions & 0 deletions api/web/src/stores/cots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,33 @@ export const useCOTStore = defineStore('cots', {
}
}

for (const cot of this.pending.values()) {
const render = cot.as_rendered();

if (this.cots.has(cot.id)) {
diff.update.push({
id: render.id,
addOrUpdateProperties: Object.keys(render.properties).map((key) => {
return { key, value: render.properties[key] }
}),
newGeometry: render.geometry
})
} else {
diff.add.push(render);
}

this.cots.set(cot.id, cot);
}

this.pending.clear();

for (const id of this.pendingDelete) {
diff.remove.push(id);
this.cots.delete(id);
}

this.pendingDelete.clear();

return diff;
},

Expand Down

0 comments on commit 1722e5b

Please sign in to comment.