File tree Expand file tree Collapse file tree 5 files changed +11
-1
lines changed
Expand file tree Collapse file tree 5 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ module.exports = {
4444 tabWidth : 4
4545 } ] ,
4646 'no-trailing-spaces' : 'off' ,
47+ 'no-plusplus' : 'off'
4748 } ,
4849 parserOptions : {
4950 parser : 'babel-eslint' ,
Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ export default {
6868 tweetId: this .tweetId ,
6969 text: this .text ,
7070 });
71+
7172 this .clearInput ();
7273 },
7374 },
Original file line number Diff line number Diff line change 11import api from '@/api/Api' ;
22import { SET_LOADING } from '../../mutationTypes' ;
33import { SET_COMMENTS , ADD_COMMENT } from './mutationTypes' ;
4+ import { INCREMENT_COMMENTS_COUNT } from '../tweet/mutationTypes' ;
45import { commentMapper } from '@/services/Normalizer' ;
56
67export default {
@@ -30,6 +31,7 @@ export default {
3031 const comment = await api . post ( '/comments' , { tweet_id : tweetId , body : text } ) ;
3132
3233 commit ( ADD_COMMENT , { tweetId, comment } ) ;
34+ commit ( `tweet/${ INCREMENT_COMMENTS_COUNT } ` , tweetId , { root : true } ) ;
3335 commit ( SET_LOADING , false , { root : true } ) ;
3436
3537 return Promise . resolve ( commentMapper ( comment ) ) ;
Original file line number Diff line number Diff line change @@ -2,3 +2,4 @@ export const SET_TWEETS = 'setTweets';
22export const SET_TWEET_IMAGE = 'setTweetImage' ;
33export const SET_TWEET = 'editTweet' ;
44export const DELETE_TWEET = 'deleteTweet' ;
5+ export const INCREMENT_COMMENTS_COUNT = 'incrementCommentsCount' ;
Original file line number Diff line number Diff line change 22 SET_TWEETS ,
33 SET_TWEET_IMAGE ,
44 SET_TWEET ,
5- DELETE_TWEET
5+ DELETE_TWEET ,
6+ INCREMENT_COMMENTS_COUNT
67} from './mutationTypes' ;
78import { tweetMapper } from '@/services/Normalizer' ;
89
@@ -29,5 +30,9 @@ export default {
2930
3031 [ DELETE_TWEET ] : ( state , id ) => {
3132 delete state . tweets [ id ] ;
33+ } ,
34+
35+ [ INCREMENT_COMMENTS_COUNT ] : ( state , id ) => {
36+ state . tweets [ id ] . commentsCount ++ ;
3237 }
3338} ;
You can’t perform that action at this time.
0 commit comments