Skip to content

Commit

Permalink
fix: prevent in place reverse in setDatastore
Browse files Browse the repository at this point in the history
  • Loading branch information
mint-dewit committed Nov 14, 2022
1 parent 8665273 commit 473ab71
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/timeline-state-resolver/src/conductor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,8 @@ export class Conductor extends EventEmitter<ConductorEvents> {

for (const deviceId of affectedDevices) {
const toBeFilled = _.compact([
this._deviceStates[deviceId].reverse().find((s) => s.time <= this.getCurrentTime()), // one state before now
// shallow clone so we don't reverse the array in place
[...this._deviceStates[deviceId]].reverse().find((s) => s.time <= this.getCurrentTime()), // one state before now
...this._deviceStates[deviceId].filter((s) => s.time > this.getCurrentTime()), // all states after now
])

Expand Down

0 comments on commit 473ab71

Please sign in to comment.