Move supportform related redux property in a different reducer
Summary: This diff moves support form related redux prop to a separate reducer under separate supportForm property. Reviewed By: passy Differential Revision: D18272436 fbshipit-source-id: b64c4e041d8dacd305a71db255752a310a46b0d1
This commit is contained in:
committed by
Facebook Github Bot
parent
9ec4ef67ad
commit
7c69aba8fa
@@ -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<string>;
|
||||
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,
|
||||
});
|
||||
|
||||
@@ -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<State, Actions>;
|
||||
@@ -107,6 +113,7 @@ export default combineReducers<State, Actions>({
|
||||
notifications,
|
||||
),
|
||||
plugins,
|
||||
supportForm,
|
||||
user: persistReducer(
|
||||
{
|
||||
key: 'user',
|
||||
|
||||
46
src/reducers/supportForm.tsx
Normal file
46
src/reducers/supportForm.tsx
Normal file
@@ -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,
|
||||
});
|
||||
Reference in New Issue
Block a user