Skip to content

Commit cde88ab

Browse files
Update temporary modification
1 parent 10c8f1a commit cde88ab

File tree

1 file changed

+39
-6
lines changed

1 file changed

+39
-6
lines changed

fission/src/ui/panels/configuring/assembly-config/interfaces/scoring/ScoringZoneConfigInterface.tsx

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,45 @@ const ZoneConfigInterface: React.FC<ZoneConfigProps> = ({ selectedField, selecte
257257
)
258258

259259
const handleTemporaryModification = () => {
260-
// For temporary modification, just save the changes to the current session
261-
// without persisting to the field file cache
262-
handleSave()
263-
264-
// Save all zones to ensure the changes are persisted to preferences
265-
saveAllZones()
260+
if (gizmoRef.current && selectedField) {
261+
save(
262+
selectedField,
263+
selectedZone,
264+
name,
265+
alliance,
266+
points,
267+
destroy,
268+
persistent,
269+
gizmoRef.current,
270+
selectedNode
271+
)
272+
273+
const fieldZones = selectedField.fieldPreferences?.scoringZones
274+
if (fieldZones) {
275+
const zoneIndex = fieldZones.findIndex(z =>
276+
z === selectedZone ||
277+
(z.name === originalZoneRef.current.name &&
278+
z.alliance === originalZoneRef.current.alliance &&
279+
z.parentNode === originalZoneRef.current.parentNode &&
280+
JSON.stringify(z.deltaTransformation) === JSON.stringify(originalZoneRef.current.deltaTransformation))
281+
)
282+
283+
if (zoneIndex >= 0) {
284+
fieldZones[zoneIndex] = {
285+
name,
286+
alliance,
287+
parentNode: selectedNode,
288+
points,
289+
destroyGamepiece: destroy,
290+
persistentPoints: persistent,
291+
deltaTransformation: selectedZone.deltaTransformation
292+
}
293+
}
294+
}
295+
296+
PreferencesSystem.savePreferences()
297+
selectedField.updateScoringZones()
298+
}
266299

267300
setConfirmationModal({ isOpen: false, pendingSave: false })
268301
if (panel) closePanel(panel.id, CloseType.Accept)

0 commit comments

Comments
 (0)