Skip to content

Commit

Permalink
fix all trajectories being stale on first load of a file
Browse files Browse the repository at this point in the history
  • Loading branch information
shueja committed Mar 5, 2024
1 parent 0626ff1 commit 9b1ef83
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/document/HolonomicPathStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,6 @@ export const HolonomicPathStore = types
) {
self.generatedWaypoints = savedPath.trajectoryWaypoints;
}
self.isTrajectoryStale = savedPath.isTrajectoryStale ?? false;
self.usesControlIntervalGuessing =
savedPath.usesControlIntervalGuessing;
self.defaultControlIntervalCount =
Expand Down Expand Up @@ -707,6 +706,8 @@ export const HolonomicPathStore = types
marker.command.fromSavedCommand(saved.command);
this.addEventMarker(marker);
});
self.setIsTrajectoryStale(savedPath.isTrajectoryStale ?? false);
// this needs to be last or populating other parts of the path will set it to false
},
addObstacle(obstacle: ICircularObstacleStore) {
self.obstacles.push(obstacle);
Expand Down Expand Up @@ -804,13 +805,20 @@ export const HolonomicPathStore = types
let exporter: (uuid: string) => void;
const afterCreate = () => {
// Anything accessed in here will cause the trajectory to be marked stale
staleDisposer = autorun(() => {
// this is a reaction, not an autorun so that the effect does not happen
// when mobx first runs it to determine dependencies.
staleDisposer = reaction(() => {
toJS(self.waypoints);
toJS(self.constraints);
// does not need toJS to do a deep check on this, since it's just a boolean
self.usesControlIntervalGuessing;
toJS(self.obstacles);
self.setIsTrajectoryStale(true);
return true;
},
(value) => {
if (value) {
self.setIsTrajectoryStale(true);
}
});
autosaveDisposer = reaction(
() => {
Expand Down

0 comments on commit 9b1ef83

Please sign in to comment.