Skip to content

Commit

Permalink
fix: enable press to talk button
Browse files Browse the repository at this point in the history
use same cb for hotkey and press to talk button
  • Loading branch information
martinstark committed Apr 26, 2024
1 parent 141b56d commit 783c615
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/components/production-line/long-press-to-talk-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { PrimaryButton } from "../landing-page/form-elements";
import { isMobile } from "../../bowser";

type TLongPressToTalkButton = {
setMicMute: (input: boolean) => void;
muteInput: (input: boolean) => void;
};

const Button = styled(PrimaryButton)`
Expand All @@ -31,7 +31,7 @@ const Button = styled(PrimaryButton)`
`;

export const LongPressToTalkButton = ({
setMicMute,
muteInput,
}: TLongPressToTalkButton) => {
const [isToggled, setIsToggled] = useState(false);
const [longPressTimeout, setLongPressTimeout] =
Expand All @@ -55,14 +55,14 @@ export const LongPressToTalkButton = ({
switch (e.type) {
case "pointerdown":
timeoutId = setTimeout(() => {
setMicMute(false);
muteInput(false);
setIsToggled(true);
}, 300);
setLongPressTimeout(timeoutId);
break;
case "pointerup":
setIsToggled(false);
setMicMute(true);
muteInput(true);
clearTimeout(longPressTimeout);
break;
default:
Expand Down
4 changes: 1 addition & 3 deletions src/components/production-line/production-line.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,7 @@ export const ProductionLine: FC = () => {

{inputAudioStream && inputAudioStream !== "no-device" && (
<LongPressWrapper>
<LongPressToTalkButton
setMicMute={(input: boolean) => setIsInputMuted(input)}
/>
<LongPressToTalkButton muteInput={muteInput} />
</LongPressWrapper>
)}

Expand Down

0 comments on commit 783c615

Please sign in to comment.