Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Clients/Angular/finki-chattery/src/app/core/state/question-state/question.reducers.ts

    r7c3e6a8 ra3b5f34  
    1 import { VoteType } from 'src/app/shared-app/models';
    21import { QuestionAction, QuestionActionTypes } from './question.actions';
    32import { initialState, QuestionState } from './question.state';
     
    2625        searchQuestionsQuery: action.query
    2726      };
    28     case QuestionActionTypes.VoteAnswerSuccess: {
    29       if (state.question) {
    30         return {
    31           ...state,
    32           question: {
    33             ...state.question,
    34             answers: state.question.answers.map((x) => {
    35               if (x.uid === action.payload.answerUid) {
    36                 let votesCountNew = x.votesCount;
    37 
    38                 switch (action.payload.voteType) {
    39                   case VoteType.Upvote:
    40                     votesCountNew++;
    41                     break;
    42                   case VoteType.Downvote:
    43                     votesCountNew--;
    44                     break;
    45                 }
    46 
    47                 return {
    48                   ...x,
    49                   votesCount: votesCountNew
    50                 };
    51               }
    52 
    53               return x;
    54             })
    55           }
    56         };
    57       }
    58 
    59       return {
    60         ...state
    61       };
    62     }
    6327    case QuestionActionTypes.EffectStartedWorking: {
    6428      return {
Note: See TracChangeset for help on using the changeset viewer.