Skip to content

Commit

Permalink
fix: don't play tick sound on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Nov 20, 2024
1 parent 60b9e35 commit 343e864
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/Form.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { UseChatHelpers } from 'ai/react';
import { isMobile } from 'src/helpers';
import { drop, tick } from 'src/sounds';

import SubmitButton from './SubmitButton';
Expand All @@ -24,7 +25,9 @@ export default function Form(props: Props) {
class="border-input focus-visible:ring-ring flex h-9 w-full flex-1 rounded-md border bg-transparent px-3 py-1 text-base shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50"
onInput={(event) => {
props.onChange(event);
tick.play();
if (!isMobile) {
tick.play();
}
}}
placeholder="Type your guess..."
value={props.value}
Expand Down
1 change: 1 addition & 0 deletions src/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './guesses';
export * from './mobile';
4 changes: 4 additions & 0 deletions src/helpers/mobile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const MOBILE_REGEX =
/Android|Blackberry|IEMobile|Opera Mini|Windows Phone|iPad|iPhone|iPod|webOS/i;

export const isMobile = MOBILE_REGEX.test(navigator.userAgent);

0 comments on commit 343e864

Please sign in to comment.