Commit Graph

209 Commits

Author SHA1 Message Date
Rapptz
616137875b Fix memory leak with the view store when removing items
The previous code would maintain items in the dispatch mapping if
nested children were removed between calls because it would only
remove items that are live in the view at the point of removal. This
meant that calling something like ActionRow.clear_items() would keep
all the removed items within the mapping and would not be evicted.

This attempts to fix it by maintaining a cache state snapshot and
making a diff between the two versions to know which keys are now safe
to delete since they are no longer in the live view at all.
2026-03-02 11:33:51 -05:00
Rapptz
ef1cb6a089 Prevent empty dictionaries from being added to the ViewStore
Fix #10405
2026-02-23 02:31:55 -05:00
Michael
38d5d8e47a Use walk_children within remove_view 2026-02-22 16:47:15 -05:00
Soheab
e5263c0870 Add support for new modal components 2026-02-22 16:43:06 -05:00
Steve C
dae46f7d0f Add generics to Interaction params 2026-02-22 15:59:46 -05:00
Rapptz
a7d42b9906 Fallback to Item.row when converting to Modal component list
Fix #10397
2026-02-04 18:57:04 -05:00
Rapptz
3ab09be13c Invert View.is_finished condition when there is no associated Future 2026-01-28 16:58:55 -05:00
Michael
bcea13e993 Allow ui.View initialization without a running event loop 2026-01-13 18:08:53 -05:00
Rapptz
0052878983 Guard against Item.view being None when dispatching 2025-12-21 12:18:05 -05:00
Soheab
9580898c97 Detach view from item when removed 2025-11-12 20:02:19 -05:00
DA344
e2cf721e9c Fix container items having out of date internal state 2025-11-07 18:53:04 -05:00
Sacul
8f2cb60700 Fix inaccurate total_children_count property in modals 2025-10-28 07:51:15 -04:00
Rapptz
88294fe352 Fix Section.accessory setter not updating view bindings 2025-10-08 08:52:11 -04:00
Rapptz
651699fcd2 Remove buggy and unintentional Container.children setter 2025-10-05 02:45:23 -04:00
Rapptz
8f90b7d534 Add shoutout to Button and Thumbnail accessories for Section 2025-09-28 16:07:30 -04:00
Soheab_
d78636283b Correct supported types in docs for modal components 2025-09-28 16:06:17 -04:00
Soheab_
178ea664b2 Add missing required kwarg to all select classes 2025-09-28 16:06:17 -04:00
Soheab_
2d7e0614ad Add support for File Upload component 2025-09-28 16:06:17 -04:00
Soheab_
944ffe93c7 Handle resolved data for modal components and types 2025-09-28 16:06:17 -04:00
Soheab_
1d3642d1fe Fix KeyError on custom_id for modal components that don't support it 2025-09-28 16:06:17 -04:00
Rapptz
78ff16621a Fix certain component IDs not being able to be settable afterwards
Fix #10305
2025-09-28 13:05:23 -04:00
Lucas Hardt
a7f349498a Upgrade code by using f-strings and yield from 2025-09-03 05:31:59 -04:00
Sacul
44956db033 Update modal example in docstring 2025-09-02 17:05:50 -04:00
Rapptz
89d5cbd78a Move v2 item check from BaseView to View 2025-08-31 14:18:50 -04:00
Rapptz
116107d7ed Add accessory to Section.__repr__ 2025-08-26 11:54:18 -04:00
Rapptz
d5946d1cbc Fix bounds for TextInput and Label generic
Fix #10280
2025-08-25 11:29:44 -04:00
lmaotrigine
50b0d219b5 Add missing versionadded to some BaseView items 2025-08-24 13:22:35 -04:00
Rapptz
63357e0113 Revert "Add second generic parameter for view for DynamicItem"
This reverts commit fe7ce982f3.
2025-08-24 13:21:54 -04:00
Rapptz
9677dada1f Fix Modal not raising when hitting the 5 item limit 2025-08-24 09:42:41 -04:00
Rapptz
bb45e050b9 Change Modal inheritance to BaseView instead of View 2025-08-24 09:29:41 -04:00
Rapptz
fe7ce982f3 Add second generic parameter for view for DynamicItem 2025-08-24 09:12:12 -04:00
Rapptz
6d5013030b Flip if statement for wrapped ActionRow components in modals 2025-08-22 19:28:37 -04:00
Rapptz
de09031899 Allow TextDisplay as a top-level component in modals 2025-08-22 19:18:33 -04:00
Rapptz
9bda89b0d6 Update total count tracking to always consider the wrapper object 2025-08-21 22:20:12 -04:00
DA344
0309aac335 Add a swap method for dynamic item's dispatching 2025-08-20 18:52:31 -04:00
Rapptz
20f4bc40ad Remove outdated comment 2025-08-20 06:53:03 -04:00
Rapptz
59e28af19f Fix Section.accessory being MISSING 2025-08-20 06:50:23 -04:00
Sacul
27d69e98e2 Fix note in button decorator in action row 2025-08-20 04:04:50 -04:00
DA344
24aa98b923 Fix Section.children and accessory's parent being None 2025-08-19 20:50:57 -04:00
Rapptz
9dbf13c2f9 Document Section.accessory as an attribute 2025-08-19 04:25:29 -04:00
Rapptz
44a44e938f Reformat entire project with ruff instead of black 2025-08-18 20:16:10 -04:00
Rapptz
3ef6272e07 Fix error with View.from_message when having multiple items 2025-08-18 19:04:19 -04:00
Rapptz
d58c055c5b Remove unused import 2025-08-18 15:07:44 -04:00
Rapptz
5d49f11709 Remove View.from_dict typing 2025-08-18 15:00:51 -04:00
Rapptz
fc12a41cdf Run black 2025-08-18 14:49:32 -04:00
Rapptz
064cb7af71 Add View.total_children_count 2025-08-18 14:42:55 -04:00
Rapptz
f08c042217 Add content_length method to LayoutView and container items 2025-08-18 14:33:15 -04:00
Rapptz
6f6d990195 Fix type error with ItemCallbackType 2025-08-18 07:13:50 -04:00
Rapptz
4854c56d58 Allow discord.File in places where UnfurledMediaItem or str are allowed 2025-08-18 06:11:59 -04:00
Rapptz
9ef5b054e5 Refactor total children count to an overrideable method 2025-08-18 04:49:20 -04:00