import { h } from 'preact'; import { useState, useEffect } from 'preact/hooks'; import htm from 'htm'; import { api } from '../api.js'; const html = htm.bind(h); const SOURCE_ICONS = { TUNEIN: '📻', SPOTIFY: '🎵', AMAZON: '🎶', PANDORA: '🎸', DEEZER: '🎵', IHEART: '📻', BLUETOOTH: '📶', AUX: '🔌', LOCAL_MUSIC: '💽', STORED_MUSIC: '💽', }; export function Recents({ deviceId }) { const [items, setItems] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { if (!deviceId) return; api.recents(deviceId).then(resp => { setItems(resp.data?.Items ?? []); }).catch(() => { setItems([]); }).finally(() => setLoading(false)); }, [deviceId]); if (loading) return html`