Skip to content

Commit

Permalink
fix: filter mappings by deviceid
Browse files Browse the repository at this point in the history
  • Loading branch information
mint-dewit committed Aug 28, 2024
1 parent 6cecf90 commit f4402dd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
20 changes: 13 additions & 7 deletions packages/timeline-state-resolver/src/__tests__/conductor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,16 @@ describe('Conductor', () => {
deviceId: 'device1',
options: {},
}
const myLayerMapping: Mappings = {
const device0Mappings: Mappings = {
myLayer0: myLayerMapping0,
}
const device1Mappings: Mappings = {
myLayer1: myLayerMapping1,
}
const myLayerMapping: Mappings = {
...device0Mappings,
...device1Mappings,
}

const conductor = new Conductor({
multiThreadedResolver: false,
Expand Down Expand Up @@ -139,22 +145,22 @@ describe('Conductor', () => {
},
time: 10005,
}),
myLayerMapping // TODO - is this correct?
device0Mappings // TODO - is this correct?
)
expect(device0.handleState).toHaveBeenNthCalledWith(
2,
expect.objectContaining({
time: 11000,
}),
myLayerMapping // TODO - is this correct?
device0Mappings // TODO - is this correct?
)
expect(device0.handleState).toHaveBeenNthCalledWith(
3,
expect.objectContaining({
layers: {},
time: 12000,
}),
myLayerMapping // TODO - is this correct?
device0Mappings // TODO - is this correct?
)

// Ensure device1 has been fed sensible states
Expand All @@ -165,7 +171,7 @@ describe('Conductor', () => {
expect.objectContaining({
layers: {},
}),
myLayerMapping // TODO - is this correct?
device1Mappings // TODO - is this correct?
)
expect(device1.handleState).toHaveBeenNthCalledWith(
2,
Expand All @@ -180,14 +186,14 @@ describe('Conductor', () => {
}),
},
}),
myLayerMapping // TODO - is this correct?
device1Mappings // TODO - is this correct?
)
expect(device1.handleState).toHaveBeenNthCalledWith(
3,
expect.objectContaining({
layers: {},
}),
myLayerMapping // TODO - is this correct?
device1Mappings // TODO - is this correct?
)

// Remove the device
Expand Down
7 changes: 6 additions & 1 deletion packages/timeline-state-resolver/src/conductor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1087,8 +1087,13 @@ export class Conductor extends EventEmitter<ConductorEvents> {
deviceId: string,
time: number,
state: Timeline.TimelineState<TSRTimelineContent>,
mappings: Mappings
unfilteredMappings: Mappings
) {
// only take mappings that are for this deviceId
const mappings = Object.fromEntries(
Object.entries<Mapping<unknown>>(unfilteredMappings).filter(([_, mapping]) => mapping.deviceId === deviceId)
)

if (!this._deviceStates[deviceId]) this._deviceStates[deviceId] = []

// find all references to the datastore that are in this state
Expand Down

0 comments on commit f4402dd

Please sign in to comment.