File tree Expand file tree Collapse file tree
components/common/PostCard Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import {
1818} from "../post" ;
1919import {
2020 infiniteQueryOptions ,
21+ QueryClient ,
2122 queryOptions ,
2223 UseMutationOptions ,
2324} from "@tanstack/react-query" ;
@@ -92,15 +93,20 @@ export const postQueries = {
9293
9394 delete : ( {
9495 postId,
95- navigate ,
96+ queryClient ,
9697 } : {
9798 postId : number ;
98- navigate : NavigateFunction ;
99+ queryClient : QueryClient ;
99100 } ) => ( {
100101 mutationKey : [ ...postQueries . all ( ) , "delete" , postId ] ,
101102 mutationFn : ( ) => deletePost ( postId ) ,
102103 onSuccess : ( ) => {
103- navigate ( "/" ) ;
104+ queryClient . invalidateQueries ( {
105+ queryKey : [ ...postQueries . all ( ) , "list" ] ,
106+ } ) ;
107+ queryClient . invalidateQueries ( {
108+ queryKey : [ ...postQueries . all ( ) , "userPostList" ] ,
109+ } ) ;
104110 } ,
105111 onError : ( error : AxiosError < IError > ) => {
106112 if ( error . response ?. status !== 401 ) {
Original file line number Diff line number Diff line change 11import { useState } from "react" ;
22import { Button } from "../../ui/button" ;
33import { useNavigate } from "react-router-dom" ;
4- import { useMutation } from "@tanstack/react-query" ;
4+ import { useMutation , useQueryClient } from "@tanstack/react-query" ;
55import { postQueries } from "@/api/queries/postQueries" ;
66
77export default function ContextMenu ( { postId } : { postId : number } ) {
88 const navigate = useNavigate ( ) ;
9+ const queryClient = useQueryClient ( ) ;
910 const [ isOpen , setIsOpen ] = useState < boolean > ( false ) ;
1011 const { mutate : deletePost } = useMutation ( {
11- ...postQueries . delete ( { postId, navigate } ) ,
12+ ...postQueries . delete ( { postId, queryClient } ) ,
1213 } ) ;
1314
1415 const handleKeyDown = ( e : React . KeyboardEvent ) => {
Original file line number Diff line number Diff line change @@ -43,6 +43,10 @@ export const useImageUpload = () => {
4343 try {
4444 const imageUrls = await Promise . all (
4545 selectedImages . map ( async ( image ) => {
46+ if ( image . file . size === 0 && image . preview . startsWith ( "http" ) ) {
47+ return image . preview ;
48+ }
49+
4650 const imageUrl = await uploadImageToS3 ( image . file ) ;
4751 return imageUrl ;
4852 } ) ,
You can’t perform that action at this time.
0 commit comments