Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
fix: layers disappearing when in nested folders (#101)
Browse files Browse the repository at this point in the history
* fix layers disappearing when in nested folders

* refactor flattenLayer function

Co-authored-by: KaWaite <flippindaisy@gmail.com>
  • Loading branch information
KaWaite and KaWaite committed Oct 15, 2021
1 parent 1b90322 commit 778395e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/components/molecules/Visualizer/Layers/store.ts
Expand Up @@ -73,7 +73,14 @@ export class LayerStore {

function flattenLayers(layers: Layer[] | undefined): Layer[] {
return (
layers?.reduce<Layer[]>((a, b) => [...a, b, ...(b.isVisible ? b.children ?? [] : [])], []) ?? []
layers?.reduce<Layer[]>(
(a: Layer[], b: Layer): Layer[] => [
...a,
b,
...(b.isVisible ? flattenLayers(b.children) ?? [] : []),
],
[],
) ?? []
);
}

Expand Down

0 comments on commit 778395e

Please sign in to comment.