123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- import CommentsService from "@/services/CommentsService";
- import AuthorizedUserService from "@/services/AuthorizedUserService";
- export const state = () => ({
- lastCommentsList: [],
- commentsList: []
- });
- export const mutations = {
- SET_LAST_COMMENTS_LIST(state, lastCommentsList) {
- state.lastCommentsList = lastCommentsList;
- },
- SET_COMMENTS_LIST(state, commentsList) {
- state.commentsList = commentsList
- }
- };
- export const actions = {
- getLastCommentsList({ commit }) {
- return CommentsService.getLastCommentsList()
- .then((lastCommentsList) => {
- commit("SET_LAST_COMMENTS_LIST", lastCommentsList)
- return lastCommentsList
- })
- },
- getCommentsList({commit}, pullId, pageNumber) {
- return CommentsService.getCommentsList(pullId, pageNumber)
- .then((commentsList) => {
- commit("SET_COMMENTS_LIST", commentsList)
- return commentsList
- })
- },
- createComment({ commit }, comment, token) {
- console.log(comment, token)
- return AuthorizedUserService.createComment(comment, token)
- }
- };
- export const getters = {
- lastCommentsList: state => state.lastCommentsList,
- commentsList: state => state.commentsList
- };
-
- export default {
- namespaced: true,
- state,
- getters,
- actions,
- mutations
- }
|