37 lines
969 B
JavaScript
37 lines
969 B
JavaScript
// MusicRoom - Init module
|
|
// Application initialization sequence
|
|
|
|
(function() {
|
|
const M = window.MusicRoom;
|
|
|
|
// Fetch server status/config
|
|
async function loadServerStatus() {
|
|
try {
|
|
const res = await fetch("/api/status");
|
|
M.serverStatus = await res.json();
|
|
console.log("Server status:", M.serverStatus);
|
|
} catch (e) {
|
|
console.warn("Failed to load server status");
|
|
M.serverStatus = null;
|
|
}
|
|
}
|
|
|
|
// Initialize track storage
|
|
async function initStorage() {
|
|
await TrackStorage.init();
|
|
const cached = await TrackStorage.list();
|
|
console.log(`TrackStorage: ${cached.length} tracks cached`);
|
|
}
|
|
|
|
// Initialize the application
|
|
Promise.all([initStorage(), loadServerStatus()]).then(async () => {
|
|
await M.loadLibrary();
|
|
M.loadSelectedPlaylist("all"); // Default to All Tracks
|
|
await M.loadCurrentUser();
|
|
if (M.currentUser) {
|
|
M.loadStreams();
|
|
M.loadPlaylists();
|
|
}
|
|
});
|
|
})();
|