Add launcher prefetch setting
Summary: Allows users to override the GK status of prefetching. It is implemented as a Tri-State. "Unset" means that the local Flipper config won't take precedent over the GK setting and will leave it unchanged. If a user interacts with the setting, it gets persisted into the config and will from then-on override the GK, meaning that the user has an opt-in mechanism and if we open the GK to more people, they effectively have an opt-out. Reviewed By: jknoxville Differential Revision: D18008259 fbshipit-source-id: bdfde9a8b9acf43aa60c84800a7979a29a4e9364
This commit is contained in:
committed by
Facebook Github Bot
parent
836a065e59
commit
82a253cf28
@@ -18,6 +18,7 @@ import ToggledSection from './settings/ToggledSection';
|
|||||||
import {FilePathConfigField, ConfigText} from './settings/configFields';
|
import {FilePathConfigField, ConfigText} from './settings/configFields';
|
||||||
import isEqual from 'lodash.isequal';
|
import isEqual from 'lodash.isequal';
|
||||||
import restartFlipper from '../utils/restartFlipper';
|
import restartFlipper from '../utils/restartFlipper';
|
||||||
|
import LauncherSettingsPanel from '../fb-stubs/LauncherSettingsPanel';
|
||||||
|
|
||||||
const Container = styled(FlexColumn)({
|
const Container = styled(FlexColumn)({
|
||||||
padding: 20,
|
padding: 20,
|
||||||
@@ -102,6 +103,17 @@ class SettingsSheet extends Component<Props, State> {
|
|||||||
frozen
|
frozen
|
||||||
/>
|
/>
|
||||||
</ToggledSection>
|
</ToggledSection>
|
||||||
|
<LauncherSettingsPanel
|
||||||
|
enabledInConfig={this.state.updatedSettings.enablePrefetching}
|
||||||
|
onChange={v => {
|
||||||
|
this.setState({
|
||||||
|
updatedSettings: {
|
||||||
|
...this.state.updatedSettings,
|
||||||
|
enablePrefetching: v,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<br />
|
<br />
|
||||||
<FlexRow>
|
<FlexRow>
|
||||||
<Spacer />
|
<Spacer />
|
||||||
|
|||||||
17
src/fb-stubs/LauncherSettingsPanel.tsx
Normal file
17
src/fb-stubs/LauncherSettingsPanel.tsx
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/**
|
||||||
|
* 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 {Tristate} from 'src/reducers/settings';
|
||||||
|
|
||||||
|
export default function(_props: {
|
||||||
|
enabledInConfig: Tristate;
|
||||||
|
onChange: (v: Tristate) => void;
|
||||||
|
}) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
@@ -8,3 +8,4 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export default async function setupPrefetcher() {}
|
export default async function setupPrefetcher() {}
|
||||||
|
export const shouldInstallPrefetcher = () => false;
|
||||||
|
|||||||
@@ -9,9 +9,21 @@
|
|||||||
|
|
||||||
import {Actions} from './index';
|
import {Actions} from './index';
|
||||||
|
|
||||||
|
export enum Tristate {
|
||||||
|
True,
|
||||||
|
False,
|
||||||
|
Unset,
|
||||||
|
}
|
||||||
|
|
||||||
export type Settings = {
|
export type Settings = {
|
||||||
androidHome: string;
|
androidHome: string;
|
||||||
enableAndroid: boolean;
|
enableAndroid: boolean;
|
||||||
|
/**
|
||||||
|
* If unset, this will assume the value of the GK setting.
|
||||||
|
* Note that this setting has no effect in the open source version
|
||||||
|
* of Flipper.
|
||||||
|
*/
|
||||||
|
enablePrefetching: Tristate;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Action =
|
export type Action =
|
||||||
@@ -24,6 +36,7 @@ export type Action =
|
|||||||
const initialState: Settings = {
|
const initialState: Settings = {
|
||||||
androidHome: '/opt/android_sdk',
|
androidHome: '/opt/android_sdk',
|
||||||
enableAndroid: true,
|
enableAndroid: true,
|
||||||
|
enablePrefetching: Tristate.Unset,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function reducer(
|
export default function reducer(
|
||||||
|
|||||||
Reference in New Issue
Block a user