From a0917908bb674907755b88db0f4923278c9d18c4 Mon Sep 17 00:00:00 2001 From: jessopb <36554050+jessopb@users.noreply.github.com> Date: Wed, 15 Dec 2021 15:58:47 -0500 Subject: [PATCH] add feature to enable experimental upgrades (#7353) --- static/app-strings.json | 1 + .../settingEnablePrereleases/index.js | 17 +++++++++ .../settingEnablePrereleases/view.jsx | 25 +++++++++++++ ui/component/settingSystem/view.jsx | 35 ++++--------------- ui/constants/settings.js | 1 + ui/index.jsx | 12 +++++++ ui/redux/reducers/settings.js | 1 + 7 files changed, 64 insertions(+), 28 deletions(-) create mode 100644 ui/component/settingEnablePrereleases/index.js create mode 100644 ui/component/settingEnablePrereleases/view.jsx diff --git a/static/app-strings.json b/static/app-strings.json index 2519ea806..daa35ab0a 100644 --- a/static/app-strings.json +++ b/static/app-strings.json @@ -2225,5 +2225,6 @@ "Buy LBC": "Buy LBC", "This is information like error logging, performance tracking, and usage statistics. It includes your IP address and basic system details, but no other identifying information (unless you connect to a cloud service)": "This is information like error logging, performance tracking, and usage statistics. It includes your IP address and basic system details, but no other identifying information (unless you connect to a cloud service)", "Use official LBRY wallet servers": "Use official LBRY wallet servers", + "Enable Prerelease Updates": "Enable Prerelease Updates", "--end--": "--end--" } diff --git a/ui/component/settingEnablePrereleases/index.js b/ui/component/settingEnablePrereleases/index.js new file mode 100644 index 000000000..0db6ad3b9 --- /dev/null +++ b/ui/component/settingEnablePrereleases/index.js @@ -0,0 +1,17 @@ +import SettingEnablePrereleases from './view'; +import * as SETTINGS from 'constants/settings'; +import { connect } from 'react-redux'; +import { makeSelectClientSetting } from 'redux/selectors/settings'; +import { doSetClientSetting } from 'redux/actions/settings'; + +const select = (state) => { + return { + enablePrereleases: makeSelectClientSetting(SETTINGS.ENABLE_PRERELEASE_UPDATES)(state), + }; +}; + +const perform = (dispatch) => ({ + setClientSetting: (value) => dispatch(doSetClientSetting(SETTINGS.ENABLE_PRERELEASE_UPDATES, value)), +}); + +export default connect(select, perform)(SettingEnablePrereleases); diff --git a/ui/component/settingEnablePrereleases/view.jsx b/ui/component/settingEnablePrereleases/view.jsx new file mode 100644 index 000000000..7866b6bbc --- /dev/null +++ b/ui/component/settingEnablePrereleases/view.jsx @@ -0,0 +1,25 @@ +// @flow +import React from 'react'; +import { FormField } from 'component/common/form'; + +type Props = { + setClientSetting: (boolean) => void, + enablePrereleases: boolean, +}; +function SettingEnablePrereleases(props: Props) { + const { setClientSetting, enablePrereleases } = props; + return ( + + { + setClientSetting(!enablePrereleases); + }} + checked={enablePrereleases} + /> + + ); +} + +export default SettingEnablePrereleases; diff --git a/ui/component/settingSystem/view.jsx b/ui/component/settingSystem/view.jsx index dcc4f92e4..617b60905 100644 --- a/ui/component/settingSystem/view.jsx +++ b/ui/component/settingSystem/view.jsx @@ -17,10 +17,9 @@ import Spinner from 'component/spinner'; import { getPasswordFromCookie } from 'util/saved-passwords'; import * as DAEMON_SETTINGS from 'constants/daemon_settings'; import { formatBytes } from 'util/format-bytes'; +import SettingEnablePrereleases from 'component/settingEnablePrereleases'; -// @if TARGET='app' const IS_MAC = process.platform === 'darwin'; -// @endif const BYTES_PER_MB = 1048576; type Price = { @@ -96,10 +95,7 @@ export default function SettingSystem(props: Props) { const [blobSpaceLimitGB, setBlobSpaceLimit] = React.useState(blobLimitSetting ? blobLimitSetting / 1024 : 0); // const debouncedBlobSpaceLimitGB = useDebounce(blobSpaceLimitGB || 0, 500); const [limitSpace, setLimitSpace] = React.useState(Boolean(blobLimitSetting)); - console.log('spaceUsed', spaceUsed, 'blobLimit', blobLimitSetting); - // @if TARGET='app' const { available: ffmpegAvailable, which: ffmpegPath } = ffmpegStatus; - // @endif function onChangeEncryptWallet() { if (walletEncrypted) { @@ -140,7 +136,6 @@ export default function SettingSystem(props: Props) { // Update ffmpeg variables React.useEffect(() => { - // @if TARGET='app' const { available } = ffmpegStatus; const { ffmpeg_path: ffmpegPath } = daemonSettings; if (!available) { @@ -149,7 +144,6 @@ export default function SettingSystem(props: Props) { } findFFmpeg(); } - // @endif }, []); // eslint-disable-line react-hooks/exhaustive-deps // Update storedPassword state @@ -186,7 +180,6 @@ export default function SettingSystem(props: Props) { {/* @endif */} - {/* @if TARGET='app' */} )} - {/* @endif */} - - {/* @if TARGET='app' */} - {/* @endif */} - - {/* @if TARGET='app' */} {/* Auto launch in a hidden state doesn't work on mac https://github.com/Teamwork/node-auto-launch/issues/81 */} {!IS_MAC && ( )} - {/* @endif */} - - {/* @if TARGET='app' */} - {/* @endif */} - - {/* @if TARGET='app' */} + + + @@ -379,9 +366,6 @@ export default function SettingSystem(props: Props) { )}

- {/* @endif */} - - {/* @if TARGET='app' */} )} - {/* @endif */} - - {/* @if TARGET='app' */} - {/* @endif */} - { + if (persistDone) { + const state = store.getState(); + const enabled = makeSelectClientSetting(SETTINGS.ENABLE_PRERELEASE_UPDATES)(state); + if (enabled) { + autoUpdater.allowPrerelease = true; + } + } + }, [persistDone]); + useEffect(() => { // @if TARGET='app' moment.locale(remote.app.getLocale()); diff --git a/ui/redux/reducers/settings.js b/ui/redux/reducers/settings.js index 966c61d36..7dcdf1c65 100644 --- a/ui/redux/reducers/settings.js +++ b/ui/redux/reducers/settings.js @@ -80,6 +80,7 @@ const defaultState = { // OS [SETTINGS.AUTO_LAUNCH]: true, [SETTINGS.TO_TRAY_WHEN_CLOSED]: true, + [SETTINGS.ENABLE_PRERELEASE_UPDATES]: false, }, }; defaultState.clientSettings[SETTINGS.AUTOPLAY_NEXT] = defaultState.clientSettings[SETTINGS.AUTOPLAY_MEDIA];