Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

reducer.js 1.6KB

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