Setting to choose release channel

Summary: Add possibility to choose release channel in Flipper Settings

Reviewed By: passy

Differential Revision: D25300775

fbshipit-source-id: 55fc86f0e12b9f3a4603bb40b038f5c0e5f30b3b
This commit is contained in:
Anton Nikolaev
2020-12-03 07:21:19 -08:00
committed by Facebook GitHub Bot
parent dd7c2ab96d
commit a7573139a2
6 changed files with 45 additions and 7 deletions

View File

@@ -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,
};
}