diff --git a/src/ui/component/app/index.js b/src/ui/component/app/index.js index a9b8a7b8a..31ee09b0b 100644 --- a/src/ui/component/app/index.js +++ b/src/ui/component/app/index.js @@ -6,6 +6,7 @@ import { doFetchTransactions, doFetchChannelListMine, selectBalance } from 'lbry import { makeSelectClientSetting, selectThemePath } from 'redux/selectors/settings'; import { selectIsUpgradeAvailable, selectAutoUpdateDownloaded } from 'redux/selectors/app'; import { doDownloadUpgradeRequested, doSignIn, doSyncWithPreferences } from 'redux/actions/app'; +import { doSetClientSetting } from 'redux/actions/settings'; import App from './view'; const select = state => ({ @@ -27,6 +28,7 @@ const perform = dispatch => ({ signIn: () => dispatch(doSignIn()), requestDownloadUpgrade: () => dispatch(doDownloadUpgradeRequested()), checkSync: () => dispatch(doSyncWithPreferences()), + setSyncEnabled: value => dispatch(doSetClientSetting(SETTINGS.ENABLE_SYNC, value)), }); export default hot( diff --git a/src/ui/component/app/view.jsx b/src/ui/component/app/view.jsx index fd135a823..b4a9acd98 100644 --- a/src/ui/component/app/view.jsx +++ b/src/ui/component/app/view.jsx @@ -14,6 +14,7 @@ import FileViewer from 'component/fileViewer'; import { withRouter } from 'react-router'; import usePrevious from 'effects/use-previous'; import Button from 'component/button'; +import cookie from 'cookie'; export const MAIN_WRAPPER_CLASS = 'main-wrapper'; // @if TARGET='app' @@ -21,6 +22,8 @@ export const IS_MAC = process.platform === 'darwin'; // @endif const SYNC_INTERVAL = 1000 * 60 * 5; // 5 minutes +const { auth_token: authToken } = cookie.parse(document.cookie); + type Props = { alertError: (string | {}) => void, pageTitle: ?string, @@ -40,6 +43,7 @@ type Props = { isUpgradeAvailable: boolean, autoUpdateDownloaded: boolean, checkSync: () => void, + setSyncEnabled: boolean => void, syncEnabled: boolean, }; @@ -56,9 +60,11 @@ function App(props: Props) { autoUpdateDownloaded, isUpgradeAvailable, requestDownloadUpgrade, + setSyncEnabled, syncEnabled, checkSync, } = props; + const appRef = useRef(); const isEnhancedLayout = useKonamiListener(); const [hasSignedIn, setHasSignedIn] = useState(false); @@ -77,6 +83,17 @@ function App(props: Props) { uri = newpath + hash; } catch (e) {} + // This should not be needed and will be removed after 37 is released + // We should just be able to default the enableSync setting to true, but we don't want + // to automatically opt-in existing users. Only users that go through the new sign in flow + // should be automatically opted-in (they choose to uncheck the option and turn off sync still) + useEffect(() => { + if (!authToken) { + setSyncEnabled(true); + } + // don't pass in any props to this, we only want the initial value + }, []); + useEffect(() => { ReactModal.setAppElement(appRef.current); fetchAccessToken(); diff --git a/src/ui/component/syncToggle/view.jsx b/src/ui/component/syncToggle/view.jsx index 0a2351e13..401c5b60d 100644 --- a/src/ui/component/syncToggle/view.jsx +++ b/src/ui/component/syncToggle/view.jsx @@ -44,7 +44,7 @@ function SyncToggle(props: Props) { diff --git a/src/ui/redux/reducers/settings.js b/src/ui/redux/reducers/settings.js index 45f9e4e25..0a7b72a43 100644 --- a/src/ui/redux/reducers/settings.js +++ b/src/ui/redux/reducers/settings.js @@ -11,7 +11,7 @@ const defaultState = { // UX [SETTINGS.NEW_USER_ACKNOWLEDGED]: false, [SETTINGS.EMAIL_COLLECTION_ACKNOWLEDGED]: false, - [SETTINGS.ENABLE_SYNC]: true, + [SETTINGS.ENABLE_SYNC]: false, // UI [SETTINGS.LANGUAGE]: window.localStorage.getItem(SETTINGS.LANGUAGE) || 'en', diff --git a/src/ui/util/saved-passwords.js b/src/ui/util/saved-passwords.js index 4bfa53ad0..6990093a4 100644 --- a/src/ui/util/saved-passwords.js +++ b/src/ui/util/saved-passwords.js @@ -9,7 +9,7 @@ export const setSavedPassword = (value, saveToDisk) => { }); sessionPassword = value; - if (saveToDisk && value !== undefined && value !== null) { + if (saveToDisk && value !== undefined && value !== null && value !== '') { ipcRenderer.send('set-password', value); } }); diff --git a/static/app-strings.json b/static/app-strings.json index 3bdf9769d..00afb57aa 100644 --- a/static/app-strings.json +++ b/static/app-strings.json @@ -817,12 +817,8 @@ "Show anonymous content": "Show anonymous content", "Anonymous content is published without a channel.": "Anonymous content is published without a channel.", "settings": "settings", - "Content may be hidden on this %type% because of your %settings%": "Content may be hidden on this %type% because of your %settings%", "Content may be hidden on this %type% because of your %settings%.": "Content may be hidden on this %type% because of your %settings%.", - "Sync balance and preferences across devices.": "Sync balance and preferences across devices.", - "By continuing, I agree to the %terms% and confirm I am over the age of 13.": "By continuing, I agree to the %terms% and confirm I am over the age of 13.", "Sync": "Sync", - "Sync your balance and preferences accross LBRY apps.": "Sync your balance and preferences accross LBRY apps.", "earned and bound in tips": "earned and bound in tips", "currently staked": "currently staked" -} \ No newline at end of file +}