Displaying comments
Follow these steps to fetch and display comments:
- In the
core/components/base.component.tsfile, import theCommenttype by adding it to the existing import declaration:import { User, Post, Comment } from '@ngsocial/graphql/types';
Then, import the following highlighted types:
import {
CommentEvent,
LikeEvent,
ListCommentsEvent, MoreCommentsEvent,
PostEvent,
RemoveCommentEvent,
RemovePostEvent
} from 'src/app/shared';
- In the same file, inside the base component, define the following property:
public comments: Map<string, { result: Comment[], fetchMore: () => void }> = new Map();
This will be used to map the comments array and the fetchMore() function to the posts IDs, which will allow us to save and track the comments and pagination...