From 8566e9f424a5f0e53aafb35b79d376c39ece3d74 Mon Sep 17 00:00:00 2001 From: lukasmartinelli Date: Sat, 10 Sep 2016 16:56:52 +0200 Subject: [PATCH] Delete works again --- src/layers/list.jsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/layers/list.jsx b/src/layers/list.jsx index 6daf7ab..4146ebd 100644 --- a/src/layers/list.jsx +++ b/src/layers/list.jsx @@ -17,18 +17,18 @@ export class LayerList extends React.Component { onLayerDestroyed(deletedLayer) { //TODO: That's just horrible... + // Can we use a immutable ordered map to look up and guarantee order + // at the same time? let deleteIdx = -1 - - for (let i = 0; i < this.props.layers.length; i++) { - if(this.props.layers[i].id == deletedLayer.id) { + for (let entry of this.props.layers.entries()) { + let [i, layer] = entry + if(layer.get('id') == deletedLayer.get('id')) { deleteIdx = i break } } - const remainingLayers = this.props.layers.slice(0) - remainingLayers.splice(deleteIdx, 0) - this.props.onLayersChanged(remainingLayers) + this.props.onLayersChanged(this.props.layers.delete(deleteIdx)) } onLayerChanged(changedLayer) {