diff --git a/lib/actions/custom-server-actions.js b/lib/actions/custom-server-actions.js new file mode 100644 --- /dev/null +++ b/lib/actions/custom-server-actions.js @@ -0,0 +1,5 @@ +// @flow + +const setCustomServerActionType = 'SET_CUSTOM_SERVER'; + +export { setCustomServerActionType }; 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 @@ -1231,6 +1231,10 @@ | { +type: 'REMOVE_KEYSERVER', +payload: RemoveKeyserverPayload, + } + | { + +type: 'SET_CUSTOM_SERVER', + +payload: string, }; export type ActionPayload = ?(Object | Array<*> | $ReadOnlyArray<*> | string); diff --git a/native/profile/custom-server-modal.react.js b/native/profile/custom-server-modal.react.js --- a/native/profile/custom-server-modal.react.js +++ b/native/profile/custom-server-modal.react.js @@ -4,6 +4,7 @@ import * as React from 'react'; import { Text } from 'react-native'; +import { setCustomServerActionType } from 'lib/actions/custom-server-actions.js'; import { urlPrefixSelector } from 'lib/selectors/keyserver-selectors.js'; import type { Dispatch } from 'lib/types/redux-types.js'; import { useDispatch } from 'lib/utils/redux-utils.js'; @@ -17,7 +18,6 @@ import type { NavigationRoute } from '../navigation/route-names.js'; import { useSelector } from '../redux/redux-utils.js'; import { useStyles } from '../themes/colors.js'; -import { setCustomServer } from '../utils/url-utils.js'; export type CustomServerModalParams = { +presentedFrom: string, @@ -110,7 +110,7 @@ } if (customServer && customServer !== this.props.customServer) { this.props.dispatch({ - type: setCustomServer, + type: setCustomServerActionType, payload: customServer, }); } diff --git a/native/profile/keyserver-selection-bottom-sheet.react.js b/native/profile/keyserver-selection-bottom-sheet.react.js --- a/native/profile/keyserver-selection-bottom-sheet.react.js +++ b/native/profile/keyserver-selection-bottom-sheet.react.js @@ -5,6 +5,7 @@ import { View, Text } from 'react-native'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; +import { setCustomServerActionType } from 'lib/actions/custom-server-actions.js'; import { removeKeyserverActionType } from 'lib/actions/keyserver-actions.js'; import type { KeyserverInfo } from 'lib/types/keyserver-types.js'; import type { GlobalAccountUserInfo } from 'lib/types/user-types.js'; @@ -22,7 +23,6 @@ import type { BottomSheetRef } from '../types/bottom-sheet.js'; import Alert from '../utils/alert.js'; import { useStaffCanSee } from '../utils/staff-utils.js'; -import { setCustomServer } from '../utils/url-utils.js'; export type KeyserverSelectionBottomSheetParams = { +keyserverAdminUserInfo: GlobalAccountUserInfo, @@ -112,7 +112,7 @@ if (staffCanSee) { dispatch({ - type: setCustomServer, + type: setCustomServerActionType, payload: keyserverInfo.urlPrefix, }); } diff --git a/native/redux/action-types.js b/native/redux/action-types.js --- a/native/redux/action-types.js +++ b/native/redux/action-types.js @@ -29,10 +29,6 @@ +type: 'SET_REDUX_STATE', +payload: { +state: AppState, +hideFromMonitor: boolean }, } - | { - +type: 'SET_CUSTOM_SERVER', - +payload: string, - } | { +type: 'UPDATE_DIMENSIONS', +payload: Partial, diff --git a/native/redux/redux-setup.js b/native/redux/redux-setup.js --- a/native/redux/redux-setup.js +++ b/native/redux/redux-setup.js @@ -6,6 +6,7 @@ import thunk from 'redux-thunk'; import { setClientDBStoreActionType } from 'lib/actions/client-db-store-actions.js'; +import { setCustomServerActionType } from 'lib/actions/custom-server-actions.js'; import { siweAuthActionTypes } from 'lib/actions/siwe-actions.js'; import { logOutActionTypes, @@ -48,7 +49,7 @@ import reactotron from '../reactotron.js'; import { AppOutOfDateAlertDetails } from '../utils/alert-messages.js'; import { isStaffRelease } from '../utils/staff-utils.js'; -import { setCustomServer, getDevServerHostname } from '../utils/url-utils.js'; +import { getDevServerHostname } from '../utils/url-utils.js'; function reducer(state: AppState = defaultState, action: Action) { if (action.type === setReduxStateActionType) { @@ -145,7 +146,7 @@ return state; } - if (action.type === setCustomServer) { + if (action.type === setCustomServerActionType) { return { ...state, customServer: action.payload, diff --git a/native/utils/url-utils.js b/native/utils/url-utils.js --- a/native/utils/url-utils.js +++ b/native/utils/url-utils.js @@ -64,8 +64,6 @@ const natNodeServer: string = getDevNodeServerURLFromHostname(natDevHostname); -const setCustomServer = 'SET_CUSTOM_SERVER'; - function normalizeURL(url: string): string { return urlParseLax(url).href; } @@ -76,7 +74,6 @@ getDevServerHostname, nodeServerOptions, natNodeServer, - setCustomServer, normalizeURL, deviceIsEmulator, };