fix: archive layers no layer group references - #1087
Draft
AKnassa wants to merge 2 commits into
Draft
Conversation
`LayerManager.removeLayersWithSingleRef` discarded every layer held only
by the root layer manager. A state that defines a layer but uses a
custom layout whose viewers do not list it — `{"type":"row","children":
[{"type":"viewer","layers":[]}]}` — leaves exactly such a layer, so the
layer was silently dropped on load. Simple layouts are unaffected
because they pin the root manager directly, which disables the sweep.
Archive those layers instead of discarding them, which is what
`archived: true` in the state would have produced and what the layer
drag-and-drop code already does for layers that end up in no layer group.
Layers with no user layer are transient drag targets rather than
something the user asked for, so they are still removed.
Note this also applies when the last layer group referencing a layer goes
away, so removing a layer group now archives its layers rather than
deleting them.
Fixes google#932
A layer referenced by a layer group must be left alone by the sweep, and must become archived rather than deleted once the group's reference is released. Breaking the `refCount === 1` guard is caught only by this test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #932
What this does
A layer that is not displayed by any layer group is now archived instead of being thrown away.
Why
If a state defines a layer but uses a custom layout whose viewers do not list it, the layer used to disappear when the state was loaded. Archiving keeps it, which is what
"archived": truein the state would have produced, and it matches what the layer drag-and-drop code already does for layers that end up in no layer group. This follows the suggestion in the issue thread.What changed
Worth a reviewer's attention
This also applies when the last layer group referencing a layer goes away, so removing a layer group now archives its layers rather than deleting them.
How to see it
Load a state with a single layer and a layout such as
{"type":"row","children":[{"type":"viewer","layers":[]}]}. Before this change the layer vanished; now it appears in the layer list as archived. New unit tests insrc/layer/index.spec.tscover this along with the drag-target and already-archived cases.