mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 04:31:13 -05:00
Fix infinite loop in auto-detection
This commit is contained in:
@@ -10,29 +10,17 @@ export function useLocationAutoDetect() {
|
|||||||
// Only run auto-detection after preferences have loaded
|
// Only run auto-detection after preferences have loaded
|
||||||
if (loading) return;
|
if (loading) return;
|
||||||
|
|
||||||
console.log('🌍 useLocationAutoDetect running:', {
|
|
||||||
user: !!user,
|
|
||||||
preferences,
|
|
||||||
loading
|
|
||||||
});
|
|
||||||
|
|
||||||
// For debugging - clear the flag to test detection again
|
|
||||||
localStorage.removeItem('location_detection_attempted');
|
|
||||||
|
|
||||||
// Check if we've already attempted detection
|
// Check if we've already attempted detection
|
||||||
const hasAttemptedDetection = localStorage.getItem('location_detection_attempted');
|
const hasAttemptedDetection = localStorage.getItem('location_detection_attempted');
|
||||||
console.log('🔍 Detection attempt status:', hasAttemptedDetection);
|
|
||||||
|
|
||||||
// Auto-detect if we haven't attempted it yet and auto_detect is enabled
|
// Auto-detect if we haven't attempted it yet and auto_detect is enabled
|
||||||
if (preferences.auto_detect && !hasAttemptedDetection) {
|
if (preferences.auto_detect && !hasAttemptedDetection) {
|
||||||
console.log('🚀 Starting auto-detection...');
|
autoDetectPreferences().then(() => {
|
||||||
autoDetectPreferences().then((result) => {
|
|
||||||
console.log('✅ Auto-detection completed:', result);
|
|
||||||
localStorage.setItem('location_detection_attempted', 'true');
|
localStorage.setItem('location_detection_attempted', 'true');
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
console.error('❌ Failed to auto-detect location:', error);
|
console.error('❌ Failed to auto-detect location:', error);
|
||||||
localStorage.setItem('location_detection_attempted', 'true');
|
localStorage.setItem('location_detection_attempted', 'true');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [user, preferences, loading, autoDetectPreferences]);
|
}, [user, loading, preferences.auto_detect, autoDetectPreferences]);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user