-
Notifications
You must be signed in to change notification settings - Fork 13
Fix: disable add money button on default state + disable sound on IOS #1145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -1,5 +1,6 @@ | ||||||||||
'use client' | ||||||||||
|
||||||||||
import { DeviceType, useDeviceType } from '@/hooks/useGetDeviceType' | ||||||||||
import { useEffect, useRef } from 'react' | ||||||||||
|
||||||||||
const soundMap = { | ||||||||||
|
@@ -18,6 +19,13 @@ type SoundPlayerProps = { | |||||||||
export const SoundPlayer = ({ sound }: SoundPlayerProps) => { | ||||||||||
const audioRef = useRef<HTMLAudioElement | null>(null) | ||||||||||
|
||||||||||
const { deviceType } = useDeviceType() | ||||||||||
|
||||||||||
// Early return for iOS devices - completely disable sound | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: would benefit of a @dev TODO comment explaining that we'd want to fix this in the future |
||||||||||
if (deviceType === DeviceType.IOS) { | ||||||||||
return null | ||||||||||
} | ||||||||||
Comment on lines
+24
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: conditional Hooks violation (early return before useEffect). Apply this diff to remove the early return: - // Early return for iOS devices - completely disable sound
- if (deviceType === DeviceType.IOS) {
- return null
- } Then gate playback inside the effect and add 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||
|
||||||||||
useEffect(() => { | ||||||||||
const audioSrc = soundMap[sound] | ||||||||||
if (!audioSrc) return | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Do not start playback until deviceType is known; include deviceType in effect deps.
Guard the effect with deviceType to prevent preloading/attempted playback on iOS and avoid doing work twice. Also add deviceType to the dependency array so the effect runs once after detection.
Example (outside selected lines):
🤖 Prompt for AI Agents