diff --git a/src/api/telemetry/TelemetryCollection.js b/src/api/telemetry/TelemetryCollection.js index b15ed8331e..3b554a9fe2 100644 --- a/src/api/telemetry/TelemetryCollection.js +++ b/src/api/telemetry/TelemetryCollection.js @@ -180,6 +180,7 @@ export default class TelemetryCollection extends EventEmitter { let beforeStartOfBounds; let afterEndOfBounds; let added = []; + let addedIndices = []; // loop through, sort and dedupe for (let datum of data) { @@ -212,6 +213,7 @@ export default class TelemetryCollection extends EventEmitter { let index = endIndex || startIndex; this.boundedTelemetry.splice(index, 0, datum); + addedIndices.push(index); added.push(datum); } @@ -230,7 +232,7 @@ export default class TelemetryCollection extends EventEmitter { this.emit('add', this.boundedTelemetry); } } else { - this.emit('add', added); + this.emit('add', added, addedIndices); } } } @@ -330,7 +332,8 @@ export default class TelemetryCollection extends EventEmitter { this.boundedTelemetry = added; } - this.emit('add', added); + // Assumption is that added will be of length 1 here, so just send the last index of the boundedTelemetry in the add event + this.emit('add', added, [this.boundedTelemetry.length]); } } else { // user bounds change, reset diff --git a/src/plugins/imagery/mixins/imageryData.js b/src/plugins/imagery/mixins/imageryData.js index d5e5caad5f..ffc7f4a38b 100644 --- a/src/plugins/imagery/mixins/imageryData.js +++ b/src/plugins/imagery/mixins/imageryData.js @@ -76,9 +76,14 @@ export default { this.telemetryCollection.destroy(); }, methods: { - dataAdded(dataToAdd) { - const normalizedDataToAdd = dataToAdd.map(datum => this.normalizeDatum(datum)); - this.imageHistory = this.imageHistory.concat(normalizedDataToAdd); + dataAdded(addedItems, addedItemIndices) { + const normalizedDataToAdd = addedItems.map(datum => this.normalizeDatum(datum)); + let newImageHistory = this.imageHistory.slice(); + normalizedDataToAdd.forEach(((datum, index) => { + newImageHistory.splice(addedItemIndices[index] ?? -1, 0, datum); + })); + //Assign just once so imageHistory watchers don't get called too often + this.imageHistory = newImageHistory; }, dataCleared() { this.imageHistory = [];