diff --git a/lib/actions/tunnelbroker-actions.js b/lib/actions/tunnelbroker-actions.js new file mode 100644 --- /dev/null +++ b/lib/actions/tunnelbroker-actions.js @@ -0,0 +1,9 @@ +// @flow + +const setTBDeviceTokenActionTypes = Object.freeze({ + started: 'SET_TB_DEVICE_TOKEN_STARTED', + success: 'SET_TB_DEVICE_TOKEN_SUCCESS', + failed: 'SET_TB_DEVICE_TOKEN_FAILED', +}); + +export { setTBDeviceTokenActionTypes }; diff --git a/lib/reducers/tunnelbroker-device-token-reducer.js b/lib/reducers/tunnelbroker-device-token-reducer.js --- a/lib/reducers/tunnelbroker-device-token-reducer.js +++ b/lib/reducers/tunnelbroker-device-token-reducer.js @@ -1,6 +1,7 @@ // @flow import { setDeviceTokenActionTypes } from '../actions/device-actions.js'; +import { setTBDeviceTokenActionTypes } from '../actions/tunnelbroker-actions.js'; import type { BaseAction } from '../types/redux-types.js'; import type { TunnelbrokerDeviceToken } from '../types/tunnelbroker-device-token-types.js'; @@ -14,6 +15,9 @@ } const { deviceToken } = action.payload; return { ...state, localToken: deviceToken }; + } else if (action.type === setTBDeviceTokenActionTypes.success) { + const { deviceToken } = action.payload; + return { ...state, tunnelbrokerToken: deviceToken }; } return state; diff --git a/lib/types/redux-types.js b/lib/types/redux-types.js --- a/lib/types/redux-types.js +++ b/lib/types/redux-types.js @@ -1543,6 +1543,24 @@ +error: true, +payload: Error, +loadingInfo: LoadingInfo, + } + | { + +type: 'SET_TB_DEVICE_TOKEN_STARTED', + +loadingInfo?: LoadingInfo, + +payload?: void, + } + | { + +type: 'SET_TB_DEVICE_TOKEN_SUCCESS', + +payload: { + +deviceToken: string, + }, + +loadingInfo: LoadingInfo, + } + | { + +type: 'SET_TB_DEVICE_TOKEN_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, }, }>;