diff --git a/desktop/app/src/ReleaseChannel.tsx b/desktop/app/src/ReleaseChannel.tsx new file mode 100644 index 000000000..e3a71620f --- /dev/null +++ b/desktop/app/src/ReleaseChannel.tsx @@ -0,0 +1,16 @@ +/** + * 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 + */ + +export enum ReleaseChannel { + DEFAULT = 'default', + STABLE = 'stable', + INSIDERS = 'insiders', +} + +export default ReleaseChannel; diff --git a/desktop/app/src/chrome/SettingsSheet.tsx b/desktop/app/src/chrome/SettingsSheet.tsx index 09e87feda..cb92e81ff 100644 --- a/desktop/app/src/chrome/SettingsSheet.tsx +++ b/desktop/app/src/chrome/SettingsSheet.tsx @@ -233,6 +233,15 @@ class SettingsSheet extends Component { }, }); }} + releaseChannel={this.state.updatedLauncherSettings.releaseChannel} + onReleaseChannelChange={(v) => { + this.setState({ + updatedLauncherSettings: { + ...this.state.updatedLauncherSettings, + releaseChannel: v, + }, + }); + }} /> void; isLocalPinIgnored: boolean; onIgnoreLocalPinChange: (v: boolean) => void; + releaseChannel: ReleaseChannel; + onReleaseChannelChange: (v: ReleaseChannel) => void; }) { return null; } diff --git a/desktop/app/src/reducers/launcherSettings.tsx b/desktop/app/src/reducers/launcherSettings.tsx index cc41c32bd..33451a028 100644 --- a/desktop/app/src/reducers/launcherSettings.tsx +++ b/desktop/app/src/reducers/launcherSettings.tsx @@ -8,8 +8,10 @@ */ import {Actions} from './index'; +import ReleaseChannel from '../ReleaseChannel'; export type LauncherSettings = { + releaseChannel: ReleaseChannel; ignoreLocalPin: boolean; }; @@ -19,6 +21,7 @@ export type Action = { }; export const defaultLauncherSettings: LauncherSettings = { + releaseChannel: ReleaseChannel.DEFAULT, ignoreLocalPin: false, }; diff --git a/desktop/app/src/utils/launcherSettingsStorage.tsx b/desktop/app/src/utils/launcherSettingsStorage.tsx index f0b193edf..bf2d05b4c 100644 --- a/desktop/app/src/utils/launcherSettingsStorage.tsx +++ b/desktop/app/src/utils/launcherSettingsStorage.tsx @@ -9,12 +9,13 @@ import fs from 'fs'; import path from 'path'; -import TOML from '@iarna/toml'; +import TOML, {JsonMap} from '@iarna/toml'; import {Storage} from 'redux-persist/es/types'; import { defaultLauncherSettings, LauncherSettings, } from '../reducers/launcherSettings'; +import ReleaseChannel from '../ReleaseChannel'; export default class LauncherSettingsStorage implements Storage { constructor(readonly filepath: string) {} @@ -60,20 +61,26 @@ export default class LauncherSettingsStorage implements Storage { interface FormattedSettings { ignore_local_pin?: boolean; + release_channel?: ReleaseChannel; } function serialize(value: LauncherSettings): string { - const {ignoreLocalPin, ...rest} = value; - return TOML.stringify({ + const {ignoreLocalPin, releaseChannel, ...rest} = value; + const formattedSettings: FormattedSettings = { ...rest, ignore_local_pin: ignoreLocalPin, - }); + release_channel: releaseChannel, + }; + return TOML.stringify(formattedSettings as JsonMap); } function deserialize(content: string): LauncherSettings { - const {ignore_local_pin, ...rest} = TOML.parse(content) as FormattedSettings; + const {ignore_local_pin, release_channel, ...rest} = TOML.parse( + content, + ) as FormattedSettings; return { ...rest, ignoreLocalPin: !!ignore_local_pin, + releaseChannel: release_channel ?? ReleaseChannel.DEFAULT, }; }