mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 12:51:16 -05:00
Fix "Already Unlocked" Toast
This commit is contained in:
@@ -277,7 +277,7 @@ export function useModerationQueueManager(config: ModerationQueueManagerConfig):
|
|||||||
|
|
||||||
// Release lock if claimed
|
// Release lock if claimed
|
||||||
if (queue.currentLock?.submissionId === item.id) {
|
if (queue.currentLock?.submissionId === item.id) {
|
||||||
await queue.releaseLock(item.id);
|
await queue.releaseLock(item.id, true); // Silent release
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -176,7 +176,10 @@ export const useModerationQueue = (config?: UseModerationQueueConfig) => {
|
|||||||
}, [user, toast, startLockTimer]);
|
}, [user, toast, startLockTimer]);
|
||||||
|
|
||||||
// Release lock (manual or on completion)
|
// Release lock (manual or on completion)
|
||||||
const releaseLock = useCallback(async (submissionId: string): Promise<boolean> => {
|
const releaseLock = useCallback(async (
|
||||||
|
submissionId: string,
|
||||||
|
silent: boolean = false
|
||||||
|
): Promise<boolean> => {
|
||||||
if (!user?.id) return false;
|
if (!user?.id) return false;
|
||||||
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
@@ -201,17 +204,19 @@ export const useModerationQueue = (config?: UseModerationQueueConfig) => {
|
|||||||
|
|
||||||
fetchStats();
|
fetchStats();
|
||||||
|
|
||||||
// Show appropriate toast based on result
|
// Show appropriate toast based on result (unless silent)
|
||||||
if (data === true) {
|
if (!silent) {
|
||||||
toast({
|
if (data === true) {
|
||||||
title: 'Lock Released',
|
toast({
|
||||||
description: 'You can now claim another submission',
|
title: 'Lock Released',
|
||||||
});
|
description: 'You can now claim another submission',
|
||||||
} else {
|
});
|
||||||
toast({
|
} else {
|
||||||
title: 'Lock Already Released',
|
toast({
|
||||||
description: 'This submission was already unlocked',
|
title: 'Lock Already Released',
|
||||||
});
|
description: 'This submission was already unlocked',
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trigger refresh callback
|
// Trigger refresh callback
|
||||||
@@ -222,6 +227,8 @@ export const useModerationQueue = (config?: UseModerationQueueConfig) => {
|
|||||||
return data;
|
return data;
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error('Error releasing lock:', error);
|
console.error('Error releasing lock:', error);
|
||||||
|
|
||||||
|
// Always show error toasts even in silent mode
|
||||||
toast({
|
toast({
|
||||||
title: 'Failed to Release Lock',
|
title: 'Failed to Release Lock',
|
||||||
description: error.message || 'An error occurred',
|
description: error.message || 'An error occurred',
|
||||||
@@ -424,7 +431,7 @@ export const useModerationQueue = (config?: UseModerationQueueConfig) => {
|
|||||||
// Auto-release lock after moderation action
|
// Auto-release lock after moderation action
|
||||||
const releaseAfterAction = useCallback(async (submissionId: string, action: 'approved' | 'rejected'): Promise<void> => {
|
const releaseAfterAction = useCallback(async (submissionId: string, action: 'approved' | 'rejected'): Promise<void> => {
|
||||||
if (currentLock?.submissionId === submissionId) {
|
if (currentLock?.submissionId === submissionId) {
|
||||||
await releaseLock(submissionId);
|
await releaseLock(submissionId, true); // Silent release
|
||||||
console.log(`🔓 Auto-released lock after ${action} action`);
|
console.log(`🔓 Auto-released lock after ${action} action`);
|
||||||
}
|
}
|
||||||
}, [currentLock, releaseLock]);
|
}, [currentLock, releaseLock]);
|
||||||
|
|||||||
Reference in New Issue
Block a user