The older code attempted to be clever and sync component additions and
removals with what the message edit is doing. In some cases, this led
to the re-creation of those components causing lost attributes to be
dropped such as `_rendered_row` which would mess up handling of view
weights.
Instead of recreating the children list every time and keeping track
of additions and removals, this change just updates the old state with
the new state while ignoring any new or removed additions. This should
work fine in theory due to additions or removals already being present
before editing the View instance in the first place.
Closes#7231#7511
This allows users to call remove_item in a loop. Likewise, it prevents
the footgun of doing children.append(...) which does not uphold the
invariants with the weight system.
This is more consistent with the rest of the library which always has
the interaction as the first parameter. This has been done before in
the command extension as well, the first parameter is always either
self or the context.
Segments where readability was hampered were fixed by appropriate
format skipping directives. New code should hopefully be black
compatible. The moment they remove the -S option is probably the moment
I stop using black though.
If different persistent view instances are used within different
message_ids their callbacks will get called without differentiating
between them, leading to potential issues such as 404 errors. This
change makes it so N views with custom IDs bound to N message_ids
will no longer conflict with one another.