Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions app/client/control/components/SpotifyControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ const SpotifyControls = () => {
})
const { displayVolume } = state
const isMuted = displayVolume === 0
const [selectedDeviceId, setSelectedDeviceId] = useState<string>('')

const lastSentVolumeRef = useRef<string | null>(null)
const lastWarningTimeRef = useRef<number>(0)
Expand Down Expand Up @@ -188,17 +187,7 @@ const SpotifyControls = () => {

const activeDeviceId = devices.find((device) => device.is_active)?.id
const hrmDeviceId = hrmDevice?.id
const resolvedId =
activeDeviceId || (!selectedDeviceId ? hrmDeviceId || '' : selectedDeviceId)

useEffect(() => {
if (devices.length === 0) return

if (resolvedId && selectedDeviceId !== resolvedId) {
// eslint-disable-next-line react-hooks/set-state-in-effect
setSelectedDeviceId(resolvedId)
}
}, [devices, selectedDeviceId, resolvedId])
const resolvedId = activeDeviceId || hrmDeviceId || ''

const sendSpotifyCommand = useCallback(
(
Expand Down Expand Up @@ -411,10 +400,9 @@ const SpotifyControls = () => {
</Typography>
<FormControl fullWidth size="small">
<Select
value={selectedDeviceId}
value={resolvedId}
onChange={(e) => {
const deviceId = e.target.value as string
setSelectedDeviceId(deviceId)
if (deviceId) {
sendSpotifyCommand('TRANSFER_PLAYBACK', deviceId)
}
Expand Down
2 changes: 1 addition & 1 deletion tests/playwright/vrt-components.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ test.describe('Component-Specific VRT', () => {
await expect(menu).toHaveCSS('opacity', '1')

// Perform manual accessibility check on the specific menu element to ensure context validity
await checkAccessibility(dashboardPage)
await checkAccessibility(menu)

await takeScreenshot(menu, 'spotify-device-selector-menu.png', {
threshold: 0.2, // Tighter threshold for the Paper element
Expand Down
2 changes: 1 addition & 1 deletion tests/playwright/vrt-dashboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ test.describe('Dashboard Visual Regression Tests', () => {
const dashboard = dashboardPage.getByTestId('dashboard')
await takeScreenshot(dashboard, 'dashboard-large-desktop.png', {
mask: getDynamicContentMasks(dashboardPage),
maxDiffPixelRatio: 0.15,
maxDiffPixelRatio: 0.1,
})
})

Expand Down
Loading