Sha256: 508ae1f63fd1497bc0ec90ecaad7fc8c7ff0d9c278a9d2de210fa3e64d121022
Contents?: true
Size: 1.46 KB
Versions: 16
Compression:
Stored size: 1.46 KB
Contents
import Immutable from 'seamless-immutable'; import { FOREMAN_TASK_DETAILS_FETCH_TASK_REQUEST, FOREMAN_TASK_DETAILS_FETCH_TASK_SUCCESS, FOREMAN_TASK_DETAILS_STOP_POLLING, FOREMAN_TASK_DETAILS_START_POLLING, FOREMAN_TASK_DETAILS_TOGGLE_UNLOCK_MODAL, FOREMAN_TASK_DETAILS_TOGGLE_FORCE_UNLOCK_MODAL, } from './TaskDetailsConstants'; const initialState = Immutable({}); export default (state = initialState, action) => { const { type, payload } = action; let { taskReload, timeoutId } = state; switch (type) { case FOREMAN_TASK_DETAILS_FETCH_TASK_REQUEST: return state.set('loading', true); case FOREMAN_TASK_DETAILS_FETCH_TASK_SUCCESS: if (payload.state === 'stopped') { clearTimeout(state.timeoutId); taskReload = false; timeoutId = null; } return state.merge({ loading: false, ...payload, taskReload, timeoutId, }); case FOREMAN_TASK_DETAILS_STOP_POLLING: return state.merge({ taskReload: false, timeoutId: null }); case FOREMAN_TASK_DETAILS_START_POLLING: clearTimeout(state.timeoutId); return state.merge({ taskReload: true, timeoutId: payload.timeoutId }); case FOREMAN_TASK_DETAILS_TOGGLE_UNLOCK_MODAL: return state.set('showUnlockModal', !state.showUnlockModal); case FOREMAN_TASK_DETAILS_TOGGLE_FORCE_UNLOCK_MODAL: return state.set('showForceUnlockModal', !state.showForceUnlockModal); default: return state; } };
Version data entries
16 entries across 16 versions & 1 rubygems