fix bug and errors
This commit is contained in:
@@ -33,6 +33,10 @@ export function useFeedActions({ refresh, loadMyPosts, onAuthRequired, isAuthent
|
||||
}, [refresh, loadMyPosts]);
|
||||
|
||||
const handleDelete = useCallback(async (postId) => {
|
||||
if (!isAuthenticated) {
|
||||
onAuthRequired?.();
|
||||
return;
|
||||
}
|
||||
if (!window.confirm(t('feed.confirmDelete'))) return;
|
||||
const result = await deletePost(postId);
|
||||
if (result.success) {
|
||||
@@ -40,9 +44,13 @@ export function useFeedActions({ refresh, loadMyPosts, onAuthRequired, isAuthent
|
||||
} else {
|
||||
setError(result.error);
|
||||
}
|
||||
}, [t, deletePost, afterMutation]);
|
||||
}, [t, deletePost, afterMutation, isAuthenticated, onAuthRequired]);
|
||||
|
||||
const handleMarkFound = useCallback(async (postId) => {
|
||||
if (!isAuthenticated) {
|
||||
onAuthRequired?.();
|
||||
return;
|
||||
}
|
||||
if (!window.confirm(t('feed.confirmMarkFound'))) return;
|
||||
const result = await markAsFound(postId);
|
||||
if (result.success) {
|
||||
@@ -50,7 +58,7 @@ export function useFeedActions({ refresh, loadMyPosts, onAuthRequired, isAuthent
|
||||
} else {
|
||||
setError(result.error);
|
||||
}
|
||||
}, [t, markAsFound, afterMutation]);
|
||||
}, [t, markAsFound, afterMutation, isAuthenticated, onAuthRequired]);
|
||||
|
||||
const clearError = useCallback(() => setError(""), []);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user