mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 13:11:12 -05:00
Fix: Prevent moderation queue reload on tab focus
This commit is contained in:
@@ -894,21 +894,21 @@ export function useModerationQueueManager(config: ModerationQueueManagerConfig):
|
||||
};
|
||||
}, [user, settings.refreshMode, settings.pollInterval, loadingState, settings.useRealtimeQueue]);
|
||||
|
||||
// Extract the boolean value to prevent effect re-runs when settings object changes
|
||||
const isRefreshOnTabVisibleEnabled = settings.refreshOnTabVisible === true;
|
||||
|
||||
// Visibility change handler
|
||||
useEffect(() => {
|
||||
// HARD CHECK: Explicit boolean comparison to prevent any truthy coercion
|
||||
const isEnabled = settings.refreshOnTabVisible === true;
|
||||
|
||||
console.log("🔍 [VISIBILITY EFFECT] Hard check", {
|
||||
refreshOnTabVisible: settings.refreshOnTabVisible,
|
||||
typeOf: typeof settings.refreshOnTabVisible,
|
||||
isEnabled,
|
||||
willAttachListener: isEnabled,
|
||||
isRefreshOnTabVisibleEnabled,
|
||||
willAttachListener: isRefreshOnTabVisibleEnabled,
|
||||
timestamp: new Date().toISOString(),
|
||||
});
|
||||
|
||||
// Early return if feature is disabled
|
||||
if (!isEnabled) {
|
||||
if (!isRefreshOnTabVisibleEnabled) {
|
||||
console.log(" ✅ Feature DISABLED - skipping all visibility logic");
|
||||
console.log(" ✅ Tab focus will NOT trigger refreshes");
|
||||
|
||||
@@ -924,7 +924,7 @@ export function useModerationQueueManager(config: ModerationQueueManagerConfig):
|
||||
|
||||
const handleVisibilityChange = () => {
|
||||
// Double-check setting before doing anything (defensive check)
|
||||
if (!settings.refreshOnTabVisible) {
|
||||
if (!isRefreshOnTabVisibleEnabled) {
|
||||
console.log("⚠️ Visibility handler called but setting is disabled - ignoring");
|
||||
return;
|
||||
}
|
||||
@@ -954,7 +954,7 @@ export function useModerationQueueManager(config: ModerationQueueManagerConfig):
|
||||
document.removeEventListener("visibilitychange", handleVisibilityChange);
|
||||
console.log("🧹 Visibility listener removed");
|
||||
};
|
||||
}, [settings.refreshOnTabVisible]);
|
||||
}, [isRefreshOnTabVisibleEnabled]);
|
||||
|
||||
// Initialize realtime subscriptions
|
||||
useRealtimeSubscriptions({
|
||||
|
||||
Reference in New Issue
Block a user