diff --git a/js/accounts/auth.js b/js/accounts/auth.js index 2d09d06..2123cc6 100644 --- a/js/accounts/auth.js +++ b/js/accounts/auth.js @@ -2,6 +2,8 @@ import { auth, provider } from './config.js'; import { signInWithPopup, + signInWithRedirect, + getRedirectResult, signOut as firebaseSignOut, onAuthStateChanged, signInWithEmailAndPassword, @@ -26,6 +28,12 @@ export class AuthManager { this.authListeners.forEach((listener) => listener(user)); }); + + // Handle redirect result (for Linux/Mobile where popup might be blocked) + getRedirectResult(auth).catch((error) => { + console.error('Redirect Login failed:', error); + alert(`Login failed: ${error.message}`); + }); } onAuthStateChanged(callback) { @@ -43,11 +51,29 @@ export class AuthManager { } try { + // Check for Linux environment (Neutralino) where popups are often blocked + if (window.NL_OS === 'Linux') { + await signInWithRedirect(auth, provider); + // The page will redirect, so no return value needed immediately + return; + } + const result = await signInWithPopup(auth, provider); // The onAuthStateChanged listener will handle the rest return result.user; } catch (error) { console.error('Login failed:', error); + if (error.code === 'auth/popup-blocked') { + console.log('Popup blocked, falling back to redirect...'); + try { + await signInWithRedirect(auth, provider); + return; + } catch (redirectError) { + console.error('Redirect fallback failed:', redirectError); + alert(`Login failed: ${redirectError.message}`); + throw redirectError; + } + } alert(`Login failed: ${error.message}`); throw error; } diff --git a/js/app.js b/js/app.js index ba63c65..e3d4d0b 100644 --- a/js/app.js +++ b/js/app.js @@ -514,7 +514,7 @@ document.addEventListener('DOMContentLoaded', async () => { ui.setCurrentTrack(player.currentTrack); // Update Media Session with new track - updateMediaMetadata(player.currentTrack); + player.updateMediaSession(player.currentTrack); const currentTrackId = player.currentTrack.id; if (currentTrackId === previousTrackId) return;