pixiebrix-extension
pixiebrix-extension copied to clipboard
Clean up the add-new-extension logic + callbacks
There are duplicate addNew functions, one in GenericInsertPanel, and one returned from the useAddNewElement() hook. The logic in the various insert panels and the two different add-new functions is very convoluted. There are early returns used in places where a lot of logic is skipped in certain cases, and lots of indirection between the various panels and locally defined callbacks and hooks and redux actions, that makes it very hard to follow the logic paths when reading the code.
One bad effect of the above, is that it makes it very hard to figure out where and how to report events to mix panel for when a user adds a new extension.