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