Generalize welcome message
This will be helpful in preparation for the next step: Timeout on idle.
This commit is contained in:
parent
538f7dc5a7
commit
ceebc2edb4
1 changed files with 5 additions and 9 deletions
14
src/App.tsx
14
src/App.tsx
|
|
@ -56,7 +56,7 @@ function App() {
|
|||
const [album, setAlbum] = useState<AlbumType | null>(null);
|
||||
const [buffer, setBuffer] = useState<string[]>([]);
|
||||
const [nowPlaying, play] = useState<number>(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}
|
||||
</div>
|
||||
)
|
||||
} else if (searching) {
|
||||
return (<div className="welcome">Searching…</div>);
|
||||
} else {
|
||||
return (<div className="welcome">Scan an album to begin.</div>);
|
||||
return (<div className="welcome">{displayText}</div>);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue