diff --git a/lib/actions/device-actions.js b/lib/actions/device-actions.js --- a/lib/actions/device-actions.js +++ b/lib/actions/device-actions.js @@ -1,5 +1,6 @@ // @flow +import type { VersionResponse } from '../types/device-types.js'; import type { CallServerEndpoint } from '../utils/call-server-endpoint.js'; import { getConfig } from '../utils/config.js'; @@ -20,4 +21,23 @@ return deviceToken; }; -export { setDeviceTokenActionTypes, setDeviceToken }; +const getVersionActionTypes = Object.freeze({ + started: 'GET_VERSION_STARTED', + success: 'GET_VERSION_SUCCESS', + failed: 'GET_VERSION_FAILED', +}); +const getVersion = + (callServerEndpoint: CallServerEndpoint): (() => Promise) => + async () => { + const response = await callServerEndpoint('version'); + return { + codeVersion: response.codeVersion, + }; + }; + +export { + setDeviceTokenActionTypes, + setDeviceToken, + getVersionActionTypes, + getVersion, +}; 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 @@ -17,6 +17,7 @@ UpdateUserAvatarResponse, } from './avatar-types.js'; import type { CryptoStore } from './crypto-types.js'; +import type { VersionResponse } from './device-types.js'; import type { ClientDBDraftInfo, DraftStore } from './draft-types.js'; import type { EnabledApps, SupportedApps } from './enabled-apps.js'; import type { @@ -1142,6 +1143,22 @@ +payload: { +dataLoaded: boolean, }, + } + | { + +type: 'GET_VERSION_STARTED', + +loadingInfo?: LoadingInfo, + +payload?: void, + } + | { + +type: 'GET_VERSION_SUCCESS', + +payload: VersionResponse, + +loadingInfo: LoadingInfo, + } + | { + +type: 'GET_VERSION_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, }; export type ActionPayload = ?(Object | Array<*> | $ReadOnlyArray<*> | string);