Fix event chain bugs ()

This commit is contained in:
LumiaGG 2023-02-05 02:46:31 +08:00 committed by GitHub
parent 00479362df
commit 6af374e024
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions
pynecone

View File

@ -176,7 +176,14 @@ class Component(Base, ABC):
# If the input is a list of event handlers, create an event chain.
if isinstance(value, List):
events = [utils.call_event_handler(v, arg) for v in value]
events = []
for v in value:
if isinstance(v, EventHandler):
events.append(utils.call_event_handler(v, arg))
elif isinstance(v, Callable):
events.extend(utils.call_event_fn(v, arg))
else:
raise ValueError(f"Invalid event: {v}")
# If the input is a callable, create an event chain.
elif isinstance(value, Callable):

View File

@ -1293,6 +1293,11 @@ def fix_events(events: Optional[List[Event]], token: str) -> List[Event]:
name = format_event_handler(e.handler)
payload = dict(e.args)
# Remove any extra quotes introduced by json.dumps(..) and escape the characters.
for k, v in payload.items():
if isinstance(v, str):
payload[k] = json.loads(v)
# Create an event and append it to the list.
out.append(
Event(