mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 18:31:12 -05:00
Fix: Improve Edit and Release Lock button reliability
This commit is contained in:
@@ -414,9 +414,19 @@ export const useModerationQueue = (config?: UseModerationQueueConfig) => {
|
||||
}, [user, currentLock, toast, fetchStats]);
|
||||
|
||||
// Check if submission is locked by current user
|
||||
const isLockedByMe = useCallback((submissionId: string): boolean => {
|
||||
return currentLock?.submissionId === submissionId;
|
||||
}, [currentLock]);
|
||||
const isLockedByMe = useCallback((submissionId: string, assignedTo?: string | null, lockedUntil?: string | null): boolean => {
|
||||
// Check local state first (optimistic UI - immediate feedback)
|
||||
if (currentLock?.submissionId === submissionId) return true;
|
||||
|
||||
// Also check database state (source of truth)
|
||||
if (assignedTo && lockedUntil && user?.id) {
|
||||
const isAssignedToMe = assignedTo === user.id;
|
||||
const isLockActive = new Date(lockedUntil) > new Date();
|
||||
return isAssignedToMe && isLockActive;
|
||||
}
|
||||
|
||||
return false;
|
||||
}, [currentLock, user]);
|
||||
|
||||
// Check if submission is locked by another moderator
|
||||
const isLockedByOther = useCallback((submissionId: string, assignedTo: string | null, lockedUntil: string | null): boolean => {
|
||||
|
||||
Reference in New Issue
Block a user