mirror of https://github.com/jetkvm/kvm.git
refactor: streamline keep-alive timer management in useKeyboard hook
This commit is contained in:
parent
820e462dda
commit
a2b060b42e
|
@ -272,15 +272,13 @@ export default function useKeyboard() {
|
|||
}, []);
|
||||
|
||||
const scheduleKeepAlive = useCallback(() => {
|
||||
// Clear existing timer if it exists
|
||||
if (keepAliveTimerRef.current) {
|
||||
clearInterval(keepAliveTimerRef.current);
|
||||
}
|
||||
// Clears existing keepalive timer
|
||||
cancelKeepAlive();
|
||||
|
||||
keepAliveTimerRef.current = setInterval(() => {
|
||||
sendKeypressKeepAliveHidRpc();
|
||||
}, KEEPALIVE_INTERVAL);
|
||||
}, [sendKeypressKeepAliveHidRpc]);
|
||||
}, [cancelKeepAlive, sendKeypressKeepAliveHidRpc]);
|
||||
|
||||
// resetKeyboardState is used to reset the keyboard state to no keys pressed and no modifiers.
|
||||
// This is useful for macros and when the browser loses focus to ensure that the keyboard state
|
||||
|
|
Loading…
Reference in New Issue