From ceebc2edb44e18cc815639f7c1e1352bf4509c9c Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Thu, 12 Feb 2026 08:40:03 -0600 Subject: [PATCH] Generalize welcome message This will be helpful in preparation for the next step: Timeout on idle. --- src/App.tsx | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index dc97a78..d1944ec 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -56,7 +56,7 @@ function App() { const [album, setAlbum] = useState(null); const [buffer, setBuffer] = useState([]); const [nowPlaying, play] = useState(0); - const [searching, setSearching] = useState(false); + const [displayText, setDisplayText] = useState("Scan an album to begin."); const [paused, setPaused] = useState(true); const [currentTime, setCurrentTime] = useState(0); const [duration, setDuration] = useState(0); @@ -129,7 +129,7 @@ function App() { console.log("empty barcode; ignoring"); return; } - setSearching(true); + setDisplayText("Searching…"); console.log("Scanned barcode:", barcode); var mbRelease: IRelease | IReleaseMatch; if (barcode.startsWith("mbid:")) { @@ -145,8 +145,8 @@ function App() { inc: ['artist-credits', 'release-groups', 'genres'], // TODO }); if (searchResponse.count === 0) { - console.log("No album found for barcode:", barcode); // TODO: some kind of toast? - setSearching(false); + setDisplayText("No album found for barcode: " + barcode); + setTimeout(() => setDisplayText("Scan an album to begin."), 3000); return; } mbRelease = searchResponse.releases[0]; @@ -179,7 +179,6 @@ function App() { // # …and play! play(0); setPaused(false); - setSearching(false); } else { // Not found in Navidrome; populate with MusicBrainz data instead const fullMbRelease = await mbApi.lookup('release', mbRelease.id, ['recordings', 'artist-credits', 'release-groups']); const tracks: Track[] = fullMbRelease.media[0].tracks.map((t: ITrack) => ({ // TODO: handle multi-disc albums @@ -196,7 +195,6 @@ function App() { coverArtLink: await getCoverArtSrcURL(fullMbRelease.id, fullMbRelease['release-group']?.id || '') || '', }) console.log(album); - setSearching(false); } } @@ -231,10 +229,8 @@ function App() { {player} ) - } else if (searching) { - return (
Searching…
); } else { - return (
Scan an album to begin.
); + return (
{displayText}
); } }