Merge pull request #458 from vector-im/dbkr/fix_network_waiting_after_timeout
Fix 'waiting for network' after reaching time limit
This commit is contained in:
commit
aeec2c076e
1 changed files with 5 additions and 1 deletions
|
@ -57,13 +57,17 @@ export const PTTButton: React.FC<Props> = ({
|
||||||
const buttonRef = useRef<HTMLButtonElement>();
|
const buttonRef = useRef<HTMLButtonElement>();
|
||||||
|
|
||||||
const [activeTouchId, setActiveTouchId] = useState<number | null>(null);
|
const [activeTouchId, setActiveTouchId] = useState<number | null>(null);
|
||||||
|
const [buttonHeld, setButtonHeld] = useState(false);
|
||||||
|
|
||||||
const hold = useCallback(() => {
|
const hold = useCallback(() => {
|
||||||
// This update is delayed so the user only sees it if latency is significant
|
// This update is delayed so the user only sees it if latency is significant
|
||||||
|
if (buttonHeld) return;
|
||||||
|
setButtonHeld(true);
|
||||||
enqueueNetworkWaiting(true, 100);
|
enqueueNetworkWaiting(true, 100);
|
||||||
startTalking();
|
startTalking();
|
||||||
}, [enqueueNetworkWaiting, startTalking]);
|
}, [enqueueNetworkWaiting, startTalking, buttonHeld]);
|
||||||
const unhold = useCallback(() => {
|
const unhold = useCallback(() => {
|
||||||
|
setButtonHeld(false);
|
||||||
setNetworkWaiting(false);
|
setNetworkWaiting(false);
|
||||||
stopTalking();
|
stopTalking();
|
||||||
}, [setNetworkWaiting, stopTalking]);
|
}, [setNetworkWaiting, stopTalking]);
|
||||||
|
|
Loading…
Reference in a new issue