Skip to content

Commit

Permalink
Fix weird store handling when inside a .subscribe callback
Browse files Browse the repository at this point in the history
  • Loading branch information
MattFerraro committed Jun 1, 2024
1 parent 68d0c1e commit f840796
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions applications/web/src/components/features/Extrusion.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,31 @@
workbenchIsStale.set(true)
}
function sendUpdate() {
const faceIdsFromSelection = $currentlySelected
.filter(e => e.type === "face")
.map(e => e.id)
.sort()
updateExtrusion(id, data.sketch_id, length, faceIdsFromSelection)
function sendUpdate(specificFaceIds?: string[]) {
if (specificFaceIds) {
updateExtrusion(id, data.sketch_id, length, specificFaceIds)
} else {
const faceIdsFromSelection = $currentlySelected
.filter(e => e.type === "face")
.map(e => e.id)
.sort()
updateExtrusion(id, data.sketch_id, length, faceIdsFromSelection)
}
}
currentlySelected.subscribe(e => {
currentlySelected.subscribe(store => {
if ($featureIndex !== index) return
// log("[$currentlySelected]", $currentlySelected)
// log("[$featureIndex]", typeof $featureIndex, $featureIndex)
const faceIdsFromSelection = $currentlySelected
const faceIdsFromSelection = store
.filter(e => e.type === "face")
.map(e => e.id)
.sort()
// log("[closeAndRefresh] ids from inputs and from selection:", faceIdsFromInputs, faceIdsFromSelection)
if (arraysEqual(faceIdsFromInputs, faceIdsFromSelection)) {
// log("[closeAndRefresh] face ids are the same, no update")
} else {
// log("[closeAndRefresh] triggering update to new face Ids:", faceIdsFromSelection)
sendUpdate()
sendUpdate(faceIdsFromSelection)
}
})
Expand Down

0 comments on commit f840796

Please sign in to comment.