From b49a26c799dddd031a9f69b4ef6d99f8bfd164f0 Mon Sep 17 00:00:00 2001 From: GooJinSun Date: Sun, 2 Apr 2023 08:38:50 +0900 Subject: [PATCH] bugfix: #247 redirect /home after refetch home feed bugfix: #247 resetContent before async createPost not to save draft on submit --- .../src/components/_common/question-item/QuestionItem.jsx | 6 +----- .../src/components/_common/share-settings/ShareSettings.tsx | 6 +++++- frontend/src/components/friend-feed/FriendFeed.tsx | 3 +-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/_common/question-item/QuestionItem.jsx b/frontend/src/components/_common/question-item/QuestionItem.jsx index fa1d07fc..b604994d 100644 --- a/frontend/src/components/_common/question-item/QuestionItem.jsx +++ b/frontend/src/components/_common/question-item/QuestionItem.jsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; -import { Link, useHistory, useLocation } from 'react-router-dom'; +import { Link, useLocation } from 'react-router-dom'; import FavoriteIcon from '@material-ui/icons/Favorite'; import FavoriteBorderIcon from '@material-ui/icons/FavoriteBorder'; import CreateIcon from '@material-ui/icons/Create'; @@ -27,8 +27,6 @@ import NewResponse from './new-response/NewResponse'; export default function QuestionItem({ questionObj, onSubmit }) { const dispatch = useDispatch(); const location = useLocation(); - const history = useHistory(); - const isQuestionList = location.pathname === '/questions'; const isAnon = location?.pathname.includes('anonymous') || location?.search?.includes('anonymous=True'); @@ -84,8 +82,6 @@ export default function QuestionItem({ questionObj, onSubmit }) { const onSubmitHandler = () => { onSubmit?.(); setIsWriting(false); - - if (isQuestionList) history.push('/home'); }; return ( diff --git a/frontend/src/components/_common/share-settings/ShareSettings.tsx b/frontend/src/components/_common/share-settings/ShareSettings.tsx index 221df4a0..f93112a9 100644 --- a/frontend/src/components/_common/share-settings/ShareSettings.tsx +++ b/frontend/src/components/_common/share-settings/ShareSettings.tsx @@ -57,15 +57,19 @@ export default function ShareSettings({ ); history.push(location.pathname.slice(0, -4)); } else { + resetContent?.(); + await dispatch( createPost({ ...postObj, ...shareState }) ); - resetContent?.(); + // FIXME: feed는 캐싱하면 의도치 않게 stale한 응답을 보여줄 수 있음 refetchFriendPostList({ refetchPage: () => true }); + + if (location.pathname === '/questions') history.push('/home'); } onSubmit?.(); diff --git a/frontend/src/components/friend-feed/FriendFeed.tsx b/frontend/src/components/friend-feed/FriendFeed.tsx index 00987767..2dcced59 100644 --- a/frontend/src/components/friend-feed/FriendFeed.tsx +++ b/frontend/src/components/friend-feed/FriendFeed.tsx @@ -26,7 +26,6 @@ const FriendFeed = () => { fetchNextPage, isFetchingNextPage, isFetching, - isLoading, refetch: refetchFriendPostList } = useInfiniteFriendPostList(); @@ -71,7 +70,7 @@ const FriendFeed = () => { )}