Compare commits

...

4 Commits

Author SHA1 Message Date
Ahtisham Shahid
a3bad9ef18 Merge branch 'master' into ahtisham/INF-780 2023-02-21 16:15:09 +05:00
Ahtisham Shahid
2db3ad6000 Merge branch 'master' into ahtisham/INF-780 2023-02-20 14:44:49 +05:00
AhtishamShahid
e6b4ab4c4a refactor: removed console.log 2023-02-17 16:16:39 +05:00
AhtishamShahid
8a0269afb3 feat: added event tracking on load more response 2023-02-17 16:13:51 +05:00

View File

@@ -2,6 +2,8 @@ import { useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { sendTrackEvent } from '@edx/frontend-platform/analytics';
import { EndorsementStatus } from '../../../data/constants';
import { useDispatchWithState } from '../../../data/hooks';
import { selectThread } from '../../posts/data/selectors';
@@ -11,6 +13,16 @@ import {
} from './selectors';
import { fetchThreadComments } from './thunks';
function trackLoadMoreEvent(postId, params) {
sendTrackEvent(
'edx.forum.responses.loadMore',
{
postId,
params,
},
);
}
export function usePost(postId) {
const dispatch = useDispatch();
const thread = useSelector(selectThread(postId));
@@ -31,11 +43,15 @@ export function usePostComments(postId, endorsed = null) {
const hasMorePages = useSelector(selectThreadHasMorePages(postId, endorsed));
const currentPage = useSelector(selectThreadCurrentPage(postId, endorsed));
const handleLoadMoreResponses = async () => dispatch(fetchThreadComments(postId, {
endorsed,
page: currentPage + 1,
reverseOrder,
}));
const handleLoadMoreResponses = async () => {
const params = {
endorsed,
page: currentPage + 1,
reverseOrder,
};
await dispatch(fetchThreadComments(postId, params));
trackLoadMoreEvent(postId, params);
};
useEffect(() => {
dispatch(fetchThreadComments(postId, {