You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

reducer.js 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // @flow
  2. import { ReducerRegistry } from '../base/redux';
  3. import {
  4. ADD_FACIAL_EXPRESSION,
  5. SET_DETECTION_TIME_INTERVAL,
  6. START_FACIAL_RECOGNITION,
  7. STOP_FACIAL_RECOGNITION
  8. } from './actionTypes';
  9. const defaultState = {
  10. facialExpressions: {
  11. happy: 0,
  12. neutral: 0,
  13. surprised: 0,
  14. angry: 0,
  15. fearful: 0,
  16. disgusted: 0,
  17. sad: 0
  18. },
  19. detectionTimeInterval: -1,
  20. recognitionActive: false
  21. };
  22. ReducerRegistry.register('features/facial-recognition', (state = defaultState, action) => {
  23. switch (action.type) {
  24. case ADD_FACIAL_EXPRESSION: {
  25. state.facialExpressions[action.facialExpression] += action.duration;
  26. return state;
  27. }
  28. case SET_DETECTION_TIME_INTERVAL: {
  29. return {
  30. ...state,
  31. detectionTimeInterval: action.time
  32. };
  33. }
  34. case START_FACIAL_RECOGNITION: {
  35. return {
  36. ...state,
  37. recognitionActive: true
  38. };
  39. }
  40. case STOP_FACIAL_RECOGNITION: {
  41. return {
  42. ...state,
  43. recognitionActive: false
  44. };
  45. }
  46. }
  47. return state;
  48. });