diff --git a/src/reducers/application.tsx b/src/reducers/application.tsx index ffc80edac..3d49d0bfa 100644 --- a/src/reducers/application.tsx +++ b/src/reducers/application.tsx @@ -66,10 +66,6 @@ export type ShareType = { closeOnFinish: boolean; } & SubShareType; -export type NTUsersFormData = { - flipper_trace: string | null; -}; - export type State = { leftSidebarVisible: boolean; rightSidebarVisible: boolean; @@ -84,7 +80,6 @@ export type State = { flipperRating: number | null; statusMessages: Array; xcodeCommandLineToolsDetected: boolean; - supportForm: {webState: NTUsersFormData} | null; }; type BooleanActionType = @@ -155,12 +150,6 @@ export type Action = payload: { isDetected: boolean; }; - } - | { - type: 'SET_SUPPORT_FORM_STATE'; - payload: { - webState: NTUsersFormData; - } | null; }; export const initialState: () => State = () => ({ @@ -183,7 +172,6 @@ export const initialState: () => State = () => ({ flipperRating: null, statusMessages: [], xcodeCommandLineToolsDetected: false, - supportForm: null, }); function statusMessage(sender: string, msg: string): string { @@ -297,8 +285,6 @@ export default function reducer( return state; } else if (action.type === 'SET_XCODE_DETECTED') { return {...state, xcodeCommandLineToolsDetected: action.payload.isDetected}; - } else if (action.type === 'SET_SUPPORT_FORM_STATE') { - return {...state, supportForm: action.payload}; } else { return state; } @@ -384,10 +370,3 @@ export const setXcodeDetected = (isDetected: boolean): Action => ({ type: 'SET_XCODE_DETECTED', payload: {isDetected}, }); - -export const setSupportFormState = ( - payload: {webState: NTUsersFormData} | null, -): Action => ({ - type: 'SET_SUPPORT_FORM_STATE', - payload, -}); diff --git a/src/reducers/index.tsx b/src/reducers/index.tsx index 4f3d9124f..31485b799 100644 --- a/src/reducers/index.tsx +++ b/src/reducers/index.tsx @@ -28,6 +28,10 @@ import plugins, { State as PluginsState, Action as PluginsAction, } from './plugins'; +import supportForm, { + State as SupportFormState, + Action as SupportFormAction, +} from './supportForm'; import settings, { Settings as SettingsState, Action as SettingsAction, @@ -52,6 +56,7 @@ export type Actions = | PluginsAction | UserAction | SettingsAction + | SupportFormAction | {type: 'INIT'}; export type State = { @@ -62,6 +67,7 @@ export type State = { plugins: PluginsState; user: UserState & PersistPartial; settingsState: SettingsState & PersistPartial; + supportForm: SupportFormState; }; export type Store = ReduxStore; @@ -107,6 +113,7 @@ export default combineReducers({ notifications, ), plugins, + supportForm, user: persistReducer( { key: 'user', diff --git a/src/reducers/supportForm.tsx b/src/reducers/supportForm.tsx new file mode 100644 index 000000000..abf2ab14e --- /dev/null +++ b/src/reducers/supportForm.tsx @@ -0,0 +1,46 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +import {Actions} from './'; +export type State = { + webState: NTUsersFormData | null; +}; +export type Action = { + type: 'SET_SUPPORT_FORM_STATE'; + payload: NTUsersFormData | null; +}; + +export type NTUsersFormData = { + flipper_trace: string | null; +}; + +export const initialState: () => State = () => ({ + webState: null, +}); +export default function reducer( + state: State | undefined, + action: Actions, +): State { + state = state || initialState(); + if (action.type === 'SET_SUPPORT_FORM_STATE') { + return { + ...state, + webState: action.payload, + }; + } else { + return state; + } +} + +export const setSupportFormState = ( + payload: NTUsersFormData | null, +): Action => ({ + type: 'SET_SUPPORT_FORM_STATE', + payload, +});