Ignore:
Timestamp:
11/09/21 14:45:35 (3 years ago)
Author:
Стојков Марко <mst@…>
Branches:
dev
Children:
53bebc0, 9df3069
Parents:
7e7cc4c (diff), 48f727d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merged feature/answer-question into dev

File:
1 edited

Legend:

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

    r7e7cc4c r74ad056  
    88import { NotificationService } from '../../services/notification.service';
    99import { QuestionFacadeService } from '../question-facade.service';
    10 import { RespondToAnswerRequest, VoteAnswerRequest } from './question-state-request.models';
     10import { AnswerQuestionRequest, RespondToAnswerRequest, VoteAnswerRequest } from './question-state-request.models';
    1111import {
     12  AnswerQuestionStateResponse,
    1213  AnswerResponseQuestionStateResponse,
    1314  PreviewQuestionResponse,
     
    1617} from './question-state-response.models';
    1718import {
     19  AnswerQuestion,
     20  AnswerQuestionSuccess,
    1821  EffectFinishedWorking,
    1922  EffectFinishedWorkingError,
     
    165168    );
    166169  });
     170
     171  answerQuestion$ = createEffect(() => {
     172    return this.actions$.pipe(
     173      ofType<AnswerQuestion>(QuestionActionTypes.AnswerQuestion),
     174      mergeMap((action) => {
     175        return this.api
     176          .post<AnswerQuestionStateResponse>(`v1/questions/${action.questionUid}/answers`, new AnswerQuestionRequest(action.text))
     177          .pipe(
     178            tap((state) => this.notification.successNotification('success-answer')),
     179            switchMap((state) => [
     180              new AnswerQuestionSuccess(QuestionMapper.ToAnswerQuestionStateViewModel(state)),
     181              new EffectFinishedWorking()
     182            ]),
     183            catchError((err) => [new EffectFinishedWorkingError(err)])
     184          );
     185      })
     186    );
     187  });
    167188}
Note: See TracChangeset for help on using the changeset viewer.