We called the 'unhold' function even if the button wasn't held which
probably will have been generating unmute events even when we weren't
muted.
Also use separate handlers for events so we can have specific log lines
(and also see where the event comes from when caught in the debugger).
This is an Element project (in the vector-im repo) so the Copyright
should be for New Vector: it was incorrectly attributed to the
foundation for some files (and some files were missing headers).
If you spoke for the maximum amount of time and got cut off, the
next time you tried to speak you'd just get the 'waiting for network'
state. Key repeats would cause more delayed state timeouts to queue
up.
We were using createRef() instead of useRef() in the hook, which
meant we were always creating a new ref object and never actually
getting the ref. This must have been working before the useEventTarget
stuff due to some quirk of React / hooks...
* Avoid also getting a 'mousedown' event by making the event listener
non-passive so the preventDefault() works
* Remember the touch that pressed the button so we only un-press
when that touch ends, otherwise the button gets released if the
user taps the screen anywhere else.