From 794ddcc2758d8c592326962363c8faaae8cdff64 Mon Sep 17 00:00:00 2001 From: Victor Seiji Hariki Date: Sun, 29 Jan 2023 02:52:31 -0300 Subject: [PATCH] fix #185 janky layer things Signed-off-by: Victor Seiji Hariki --- js/ui/floating/layers.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/js/ui/floating/layers.js b/js/ui/floating/layers.js index c0d7bd8..2e8eed8 100644 --- a/js/ui/floating/layers.js +++ b/js/ui/floating/layers.js @@ -188,9 +188,13 @@ const uil = { } // Synchronizes with the layer lib - this.layers.forEach((uiLayer, index) => { - if (index === 0) uiLayer.layer.moveAfter(bgLayer); - else uiLayer.layer.moveAfter(copy[index - 1].layer); + const ids = this.layers.map((l) => l.id); + ids.forEach((id, index) => { + if (index === 0) this.layerIndex[id].layer.moveAfter(bgLayer); + else + this.layerIndex[id].layer.moveAfter( + this.layerIndex[ids[index - 1]].layer + ); }); }, @@ -401,6 +405,14 @@ class UILayer { deletable: true, }); + console.debug( + "After", + ( + (uil.layers.length > 0 && uil.layers[uil.layers.length - 1].layer) || + bgLayer + ).id + ); + this.layer = imageCollection.registerLayer(extra.key, { id: extra.id, name, @@ -451,10 +463,11 @@ commands.createCommand( "addLayer", (title, opt, state) => { const options = Object.assign({}, opt) || {}; + const id = guid(); defaultOpt(options, { - id: guid(), + id, group: null, - name: "New Layer", + name: id, key: null, deletable: true, });