mirror of
https://github.com/1j01/textual-paint.git
synced 2024-12-19 12:52:03 +03:00
Ignore duplicate events in a much less hacky way
Immediately reduce tech debt.
This commit is contained in:
parent
ea07b54315
commit
792d5c8294
@ -74,18 +74,13 @@ class PilotRecorder():
|
||||
self.next_after_exit: Callable[[], None] | None = None
|
||||
|
||||
recorder = self
|
||||
hack = True
|
||||
async def on_event(self: PaintApp, event: Event) -> None:
|
||||
# FIXME: every event is received in duplicate
|
||||
# Ignoring every other event is a really stupid way to fix it,
|
||||
# but I don't know why it's happening.
|
||||
nonlocal hack # "oh no remote hacking"
|
||||
hack = not hack # "psh this hack isn't really a hack"
|
||||
if hack:
|
||||
await original_on_event(self, event)
|
||||
return
|
||||
# Record before the event is handled, so a clicked button that closes a dialog,
|
||||
# removing the button from the DOM, will still be in the DOM when we record it.
|
||||
# Don't record forwarded events, because then every action is duplicated.
|
||||
# I don't know if recording only forwarded events would make more sense,
|
||||
# I don't claim to understand the forwarding scheme.
|
||||
if not event._forwarded:
|
||||
recorder.record_event(event)
|
||||
await original_on_event(self, event)
|
||||
self.app_on_event = on_event
|
||||
|
Loading…
Reference in New Issue
Block a user