Ignore:
File:
1 edited

Legend:

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

    r59d860c r7c3e6a8  
    77import { BaseApiService } from 'src/app/shared-app/services/base-api.service';
    88import { QuestionFacadeService } from '../question-facade.service';
    9 import { PreviewQuestionResponse, QuestionStateResponse } from './question-state.models';
     9import { VoteAnswerRequest } from './question-state-request.models';
     10import { PreviewQuestionResponse, QuestionStateResponse, VoteAnswerResponse } from './question-state-response.models';
    1011import {
    1112  EffectFinishedWorking,
     
    1920  GetSearchQuestions,
    2021  GetSearchQuestionsSuccess,
    21   QuestionActionTypes
     22  QuestionActionTypes,
     23  VoteAnswer,
     24  VoteAnswerSuccess
    2225} from './question.actions';
    2326import { QuestionMapper } from './question.mapper';
     
    103106    );
    104107  });
     108
     109  voteAnswer$ = createEffect(() => {
     110    return this.actions$.pipe(
     111      ofType<VoteAnswer>(QuestionActionTypes.VoteAnswer),
     112      mergeMap((action) => {
     113        const body = new VoteAnswerRequest(action.voteType);
     114        return this.api.post<VoteAnswerResponse>(`v1/questions/${action.questionUid}/answers/${action.answerUid}/votes`, body).pipe(
     115          switchMap((state) => [new VoteAnswerSuccess(QuestionMapper.ToVoteAnswerViewModel(state)), new EffectFinishedWorking()]),
     116          catchError((err) => [new EffectFinishedWorkingError(err)])
     117        );
     118      })
     119    );
     120  });
    105121}
Note: See TracChangeset for help on using the changeset viewer.