fix(03-03): handle popup mode where isOpen is undefined

- Modify duration useEffect to check (isOpen || isPopup)
- In popup mode, window being open means player is "open"
- Add isPopup to dependency array
- This fixes duration loading in popup mode

Root cause: Popup mode doesn't pass isOpen prop, so condition failed

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Nuwan 2026-01-14 16:28:00 +05:30
parent 8a77c0165a
commit 496e76f9af
1 changed files with 7 additions and 3 deletions

View File

@ -102,9 +102,13 @@ const JKSessionBackingTrackPlayer = ({
});
useEffect(() => {
console.log('[EFFECT] Duration useEffect triggered', { isOpen, hasBackingTrack: !!backingTrack, hasJamClient: !!jamClient });
console.log('[EFFECT] Duration useEffect triggered', { isOpen, isPopup, hasBackingTrack: !!backingTrack, hasJamClient: !!jamClient });
if (isOpen && backingTrack && jamClient) {
// For popup mode, treat as always "open" since the popup window itself indicates open state
const shouldInitialize = (isOpen || isPopup) && backingTrack && jamClient;
console.log('[EFFECT] Should initialize?', shouldInitialize);
if (shouldInitialize) {
console.log('[EFFECT] Condition passed, initializing...');
// Initialize player state when opened
setIsPlaying(false);
@ -162,7 +166,7 @@ const JKSessionBackingTrackPlayer = ({
fetchDuration();
}
}, [isOpen, backingTrack, jamClient, handleError, formatTime, clearError]);
}, [isOpen, isPopup, backingTrack, jamClient, handleError, formatTime, clearError]);
// Playback monitoring with visibility-aware polling
useEffect(() => {