diff --git a/client/src/containers/Dashboard.jsx b/client/src/containers/Dashboard.jsx index 96f1ac5..0cbf622 100644 --- a/client/src/containers/Dashboard.jsx +++ b/client/src/containers/Dashboard.jsx @@ -29,15 +29,13 @@ export default function Dashboard() { setCurrent(value); }; - const getAnswers = async ({ answer_id }) => { - const { error, answers } = await getUserAnswers({ after: answer_id }); + const getAnswers = async () => { + const { error, answers } = await getUserAnswers(); if (!error) return answers; }; - const getQuestions = async ({ question_id }) => { - const { error, questions } = await getUserQuestions({ - after: question_id, - }); + const getQuestions = async () => { + const { error, questions } = await getUserQuestions(); if (!error) return questions; }; diff --git a/client/src/containers/Search.jsx b/client/src/containers/Search.jsx index 83ef141..55db534 100644 --- a/client/src/containers/Search.jsx +++ b/client/src/containers/Search.jsx @@ -45,7 +45,7 @@ export default function Search() { - ; + ; ) } diff --git a/client/src/controllers/PaginatedListController.jsx b/client/src/controllers/PaginatedListController.jsx index b02b158..7862b65 100644 --- a/client/src/controllers/PaginatedListController.jsx +++ b/client/src/controllers/PaginatedListController.jsx @@ -3,12 +3,12 @@ import { PaginatedList } from 'components'; import { useSearchParams } from 'react-router-dom'; const rowsPerPage = 5; -export default function PaginatedListController({ count, Component, getData, noData }) { +export default function PaginatedListController({ concat = false, count, Component, getData, noData }) { const [searchParams] = useSearchParams(); const [data, setData] = useState([]); const [page, setPage] = useState(1); - const [load, setLoad] = useState(true); + const [load, setLoad] = useState(concat); const handleChangePage = (_, newPage) => { setPage(newPage); @@ -18,6 +18,7 @@ export default function PaginatedListController({ count, Component, getData, noD const loadData = async (clear) => { const newData = await getData(clear ? {} : data[data.length - 1] ?? {}); + if (newData?.length) if (clear) setData(newData); diff --git a/client/src/controllers/QAControllers/QAPaginatedListController.jsx b/client/src/controllers/QAControllers/QAPaginatedListController.jsx index 0e30777..061e4ce 100644 --- a/client/src/controllers/QAControllers/QAPaginatedListController.jsx +++ b/client/src/controllers/QAControllers/QAPaginatedListController.jsx @@ -6,8 +6,8 @@ import { getAnswerComments, getAnswers, getQuestionComments } from 'services/que export function AnswerCommentsList({ answer_id, comments: count }) { const { questionData: { question_id } } = useQuestion(); - const getData = () => - getAnswerComments(question_id, answer_id) + const getData = ({ comment_id }) => + getAnswerComments(question_id, answer_id, { after: comment_id }) .then(({ comments }) => comments.map(comment => ({ ...comment, answer_id, question_id }))) .catch(() => []);