diff --git a/discord/ui/action_row.py b/discord/ui/action_row.py index 7e6a6a37c..ec80596fd 100644 --- a/discord/ui/action_row.py +++ b/discord/ui/action_row.py @@ -207,12 +207,6 @@ class ActionRow(Item[V]): is_fully_dynamic = False return is_fully_dynamic - def is_dispatchable(self) -> bool: - return any(c.is_dispatchable() for c in self.children) - - def is_persistent(self) -> bool: - return all(c.is_persistent() for c in self.children) - def _update_children_view(self, view: LayoutView) -> None: for child in self._children: child._view = view # pyright: ignore[reportAttributeAccessIssue] diff --git a/discord/ui/container.py b/discord/ui/container.py index 6d773b483..a628f3d3e 100644 --- a/discord/ui/container.py +++ b/discord/ui/container.py @@ -213,12 +213,6 @@ class Container(Item[V]): return children - def is_dispatchable(self) -> bool: - return bool(self.__dispatchable) - - def is_persistent(self) -> bool: - return all(c.is_persistent() for c in self.children) - def __init_subclass__(cls) -> None: super().__init_subclass__() diff --git a/discord/ui/item.py b/discord/ui/item.py index 4e1c7d172..ae7a566b1 100644 --- a/discord/ui/item.py +++ b/discord/ui/item.py @@ -83,11 +83,6 @@ class Item(Generic[V]): self._max_row: int = 5 if not self._is_v2() else 40 self._parent: Optional[Item] = None - if self._is_v2(): - # this is done so v2 components can be stored on ViewStore._views - # and does not break v1 components custom_id property - self.custom_id: str = os.urandom(16).hex() - def to_component_dict(self) -> Dict[str, Any]: raise NotImplementedError diff --git a/discord/ui/section.py b/discord/ui/section.py index 320dbf4da..cfdcd2181 100644 --- a/discord/ui/section.py +++ b/discord/ui/section.py @@ -117,16 +117,6 @@ class Section(Item[V]): def _is_v2(self) -> bool: return True - # Accessory can be a button, and thus it can have a callback so, maybe - # allow for section to be dispatchable and make the callback func - # be accessory component callback, only called if accessory is - # dispatchable? - def is_dispatchable(self) -> bool: - return self.accessory.is_dispatchable() - - def is_persistent(self) -> bool: - return self.accessory.is_persistent() - def walk_children(self) -> Generator[Item[V], None, None]: """An iterator that recursively walks through all the children of this section. and it's children, if applicable. diff --git a/discord/ui/view.py b/discord/ui/view.py index b46ca871a..efea81b81 100644 --- a/discord/ui/view.py +++ b/discord/ui/view.py @@ -1057,39 +1057,13 @@ class ViewStore: dispatch_info = self._views.setdefault(message_id, {}) is_fully_dynamic = True - for item in view._children: + for item in view.walk_children(): if isinstance(item, DynamicItem): pattern = item.__discord_ui_compiled_template__ self._dynamic_items[pattern] = item.__class__ elif item.is_dispatchable(): - if getattr(item, '__discord_ui_container__', False): - is_fully_dynamic = ( - item._update_store_data( # type: ignore - dispatch_info, - self._dynamic_items, - ) - or is_fully_dynamic - ) - elif getattr(item, '__discord_ui_action_row__', False): - is_fully_dynamic = ( - item._update_store_data( # type: ignore - dispatch_info, - self._dynamic_items, - ) - or is_fully_dynamic - ) - elif getattr(item, '__discord_ui_section__', False): - accessory: Item = item.accessory # type: ignore - accessory._view = view - - if isinstance(accessory, DynamicItem): - pattern = accessory.__discord_ui_compiled_template__ - self._dynamic_items[pattern] = accessory.__class__ - else: - dispatch_info[(accessory.type.value, accessory.custom_id)] = accessory - else: - dispatch_info[(item.type.value, item.custom_id)] = item - is_fully_dynamic = False + dispatch_info[(item.type.value, item.custom_id)] = item + is_fully_dynamic = False view._cache_key = message_id if message_id is not None and not is_fully_dynamic: