diff options
| author | adamhrv <adam@ahprojects.com> | 2019-01-14 22:25:25 +0100 |
|---|---|---|
| committer | adamhrv <adam@ahprojects.com> | 2019-01-14 22:25:25 +0100 |
| commit | df9d364e3664f45c65cac5990d3d742b990217fa (patch) | |
| tree | 8842d844a5ea8e6c87599b8683009cba23262713 /client/faceAnalysis/faceAnalysis.reducer.js | |
| parent | 2fedd95fcee3f048c5f24333ffdb9bb4e13eafe2 (diff) | |
| parent | 3b2f0dc6d969fa323fe8775b4269e17c60192431 (diff) | |
Merge branch 'master' of github.com:adamhrv/megapixels_dev
Diffstat (limited to 'client/faceAnalysis/faceAnalysis.reducer.js')
| -rw-r--r-- | client/faceAnalysis/faceAnalysis.reducer.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/client/faceAnalysis/faceAnalysis.reducer.js b/client/faceAnalysis/faceAnalysis.reducer.js new file mode 100644 index 00000000..d9be7447 --- /dev/null +++ b/client/faceAnalysis/faceAnalysis.reducer.js @@ -0,0 +1,48 @@ +import * as types from '../types' + +const initialState = () => ({ + query: {}, + task: {}, + result: {}, + loading: false, + startTime: 0, + timing: 0, +}) + +export default function faceAnalysisReducer(state = initialState(), action) { + const { startTime } = state + switch (action.type) { + case types.faceAnalysis.loading: + return { + ...state, + startTime: action.ts, + timing: 0, + [action.tag]: { loading: true }, + } + + case types.faceAnalysis.loaded: + return { + ...state, + timing: action.ts - startTime, + [action.tag]: action.data, + } + + case types.faceAnalysis.poll: + return { + ...state, + timing: action.ts - startTime, + result: action.data, + } + + case types.faceAnalysis.error: + console.log('error', action) + return { + ...state, + timing: action.ts - startTime, + [action.tag]: { error: action.err }, + } + + default: + return state + } +} |
