1
0
Fork 0
freesewing/plugins/plugin-bust/tests
joostdecock 4264c81070 feat[plugin-bust]: Move conditionality to preSetDraft lifecycle hook
This plugin is used to draft designs for high bust rather than full
chest circumference. To facilitate that, we provide(d) a named export
called `withCondition` that checks whether the plugin is wanted, and if
so loads it.

Problem with that is that the conditional loading of a plugin applied
to the entire pattern. And since we support drafting patterns for
multiple sets (and use this to sample) this means that all of these sets
would either get the plugin effect or not, based on the first set.

So, to fix that, we have changed the lifecycle hook used by this plugin
to `preSetDraft` (from `preDraft`) and changed the `withCondition`
method to always return true.

This means that the plugin will always be loaded, and we have moved the
check that used to be in `withCondition` to the lifecycle hook.

In other words, this plugin will now always be loaded and will check for
each set whether it needs to do something.

This allows the conditionality to apply to each set in the pattern,
rather than to the entire pattern.

Note that conditionally loading plugins pattern-wide is still a valid
use-case. It just so happens that for this plugin, it was the wrong
approach.
2024-02-17 15:57:40 +01:00
..
plugin.test.mjs feat[plugin-bust]: Move conditionality to preSetDraft lifecycle hook 2024-02-17 15:57:40 +01:00
shared.test.mjs chore: Tweak to build plugin 2022-10-13 16:47:49 +02:00