Allow admins to edit and save video details correctly
Update the admin video editing interface to correctly save changes and refresh data by making cache invalidation and refetching asynchronous operations. Also, implement saving without closing the modal for AI description generation. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 2cd2c0bc-434c-4bc9-ad3f-b99d3897a0d1 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/2cd2c0bc-434c-4bc9-ad3f-b99d3897a0d1/n7jzC7R
This commit is contained in:
parent
1054a4c972
commit
5fb9842ad0
@ -253,18 +253,22 @@ function EditVideoDialog({
|
||||
|
||||
const updateMutation = useMutation({
|
||||
mutationFn: (data: any) => apiRequest("PATCH", `/api/admin/videos/${video.id}`, data),
|
||||
onSuccess: () => {
|
||||
onSuccess: async () => {
|
||||
toast({
|
||||
title: "Success",
|
||||
description: "Video updated successfully",
|
||||
});
|
||||
// Invalidate cache to refresh the video list - don't await since this function isn't async
|
||||
queryClient.invalidateQueries({ queryKey: ["/api/admin/videos"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["/api/videos"] });
|
||||
// Force immediate refetch
|
||||
queryClient.refetchQueries({ queryKey: ["/api/admin/videos"] });
|
||||
onOpenChange(false);
|
||||
onSuccess();
|
||||
// Invalidate cache to refresh the video list
|
||||
await queryClient.invalidateQueries({ queryKey: ["/api/admin/videos"] });
|
||||
await queryClient.invalidateQueries({ queryKey: ["/api/videos"] });
|
||||
// Force immediate refetch to get updated data
|
||||
await queryClient.refetchQueries({ queryKey: ["/api/admin/videos"] });
|
||||
|
||||
// Give some time for cache to update before closing modal
|
||||
setTimeout(() => {
|
||||
onOpenChange(false);
|
||||
onSuccess();
|
||||
}, 100);
|
||||
},
|
||||
onError: (error: any) => {
|
||||
toast({
|
||||
@ -328,7 +332,16 @@ function EditVideoDialog({
|
||||
episodeNumber: newFormData.episodeNumber ? parseInt(newFormData.episodeNumber.toString()) : null,
|
||||
tags: Array.isArray(newFormData.tags) ? newFormData.tags : []
|
||||
};
|
||||
updateMutation.mutate(processedData);
|
||||
|
||||
// Save without closing modal for AI generation
|
||||
try {
|
||||
await apiRequest("PATCH", `/api/admin/videos/${video.id}`, processedData);
|
||||
// Refresh cache after save
|
||||
await queryClient.invalidateQueries({ queryKey: ["/api/admin/videos"] });
|
||||
await queryClient.refetchQueries({ queryKey: ["/api/admin/videos"] });
|
||||
} catch (error) {
|
||||
console.error("Failed to save AI description:", error);
|
||||
}
|
||||
|
||||
toast({
|
||||
title: "Uspeh!",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user