Skip to content

Commit

Permalink
fix(phone/calls): disable backspace when calling
Browse files Browse the repository at this point in the history
  • Loading branch information
itschip committed Mar 31, 2022
1 parent 8cb5422 commit 913058d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions phone/src/os/keyboard/hooks/useKeyboardService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useCallback, useEffect, useRef } from 'react';
import { useHistory } from 'react-router-dom';
import { atom, useSetRecoilState, useRecoilValue } from 'recoil';
import { usePhone } from '@os/phone/hooks/usePhone';
import { useCall } from '@os/call/hooks/useCall';

const keyboardState = {
ArrowRight: atom({
Expand Down Expand Up @@ -49,6 +50,7 @@ const isKeyValid = (key) => validKeys.indexOf(key) !== -1;
export const useKeyboardService = () => {
const history = useHistory();
const { closePhone } = usePhone();
const { call } = useCall();

const ArrowRight = useRecoilValue(keyboardState.ArrowRight);
const ArrowLeft = useRecoilValue(keyboardState.ArrowLeft);
Expand Down Expand Up @@ -90,13 +92,13 @@ export const useKeyboardService = () => {

const backspaceHandler = useCallback(
(event) => {
if (['input', 'textarea'].includes(event.target.nodeName.toLowerCase())) {
// Dont anything if we are typing something :)
if (['input', 'textarea'].includes(event.target.nodeName.toLowerCase()) || call) {
// Dont anything if we are typing something, or if we're in a call :)
return;
}
history.goBack();
},
[history],
[history, call],
);

useEffect(
Expand Down

0 comments on commit 913058d

Please sign in to comment.