fix: load thread if thread data doesnot exist in redux (#215)

Co-authored-by: adeel.tajamul <adeel.tajamul@arbisoft.com>
This commit is contained in:
Muhammad Adeel Tajamul
2022-07-22 15:07:32 +05:00
committed by GitHub
parent 98b97d4125
commit c30637fcff

View File

@@ -11,7 +11,7 @@ import { EndorsementStatus, ThreadType } from '../../data/constants';
import { useDispatchWithState } from '../../data/hooks';
import { Post } from '../posts';
import { selectThread } from '../posts/data/selectors';
import { markThreadAsRead } from '../posts/data/thunks';
import { fetchThread, markThreadAsRead } from '../posts/data/thunks';
import { selectThreadComments, selectThreadCurrentPage, selectThreadHasMorePages } from './data/selectors';
import { fetchThreadComments } from './data/thunks';
import { Comment, ResponseEditor } from './comment';
@@ -112,7 +112,9 @@ DiscussionCommentsView.propTypes = {
function CommentsView({ intl }) {
const { postId } = useParams();
const thread = usePost(postId);
const dispatch = useDispatch();
if (!thread) {
dispatch(fetchThread(postId));
return (
<Spinner animation="border" variant="primary" data-testid="loading-indicator" />
);