call install/new after users select privacy options

This commit is contained in:
Sean Yesmunt 2021-01-25 12:35:54 -05:00
parent d7f95ddd43
commit 7152f9b04f
2 changed files with 21 additions and 1 deletions

View file

@ -1,9 +1,13 @@
import { DOMAIN } from 'config';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doSetDaemonSetting } from 'redux/actions/settings'; import { doSetDaemonSetting } from 'redux/actions/settings';
import { doSetWelcomeVersion, doToggle3PAnalytics, doSignOut } from 'redux/actions/app'; import { doSetWelcomeVersion, doToggle3PAnalytics, doSignOut } from 'redux/actions/app';
import { DAEMON_SETTINGS } from 'lbry-redux'; import { DAEMON_SETTINGS } from 'lbry-redux';
import { WELCOME_VERSION } from 'config.js'; import { WELCOME_VERSION } from 'config.js';
import { selectUserVerifiedEmail } from 'redux/selectors/user'; import { selectUserVerifiedEmail } from 'redux/selectors/user';
import { doAuthenticate } from 'redux/actions/user';
import { version as appVersion } from 'package.json';
import PrivacyAgreement from './view'; import PrivacyAgreement from './view';
const select = state => ({ const select = state => ({
@ -15,6 +19,8 @@ const perform = dispatch => ({
setShareDataInternal: share => dispatch(doSetDaemonSetting(DAEMON_SETTINGS.SHARE_USAGE_DATA, share)), setShareDataInternal: share => dispatch(doSetDaemonSetting(DAEMON_SETTINGS.SHARE_USAGE_DATA, share)),
setShareDataThirdParty: share => dispatch(doToggle3PAnalytics(share)), setShareDataThirdParty: share => dispatch(doToggle3PAnalytics(share)),
signOut: () => dispatch(doSignOut()), signOut: () => dispatch(doSignOut()),
authenticateIfSharingData: () =>
dispatch(doAuthenticate(appVersion, undefined, undefined, true, undefined, undefined, DOMAIN)),
}); });
export default connect(select, perform)(PrivacyAgreement); export default connect(select, perform)(PrivacyAgreement);

View file

@ -20,10 +20,19 @@ type Props = {
setShareDataThirdParty: boolean => void, setShareDataThirdParty: boolean => void,
history: { replace: string => void }, history: { replace: string => void },
authenticated: boolean, authenticated: boolean,
authenticateIfSharingData: () => void,
}; };
function PrivacyAgreement(props: Props) { function PrivacyAgreement(props: Props) {
const { setWelcomeVersion, setShareDataInternal, setShareDataThirdParty, history, authenticated, signOut } = props; const {
setWelcomeVersion,
setShareDataInternal,
setShareDataThirdParty,
history,
authenticated,
signOut,
authenticateIfSharingData,
} = props;
const [share, setShare] = useState(undefined); // preload const [share, setShare] = useState(undefined); // preload
const [agree, setAgree] = useState(false); // preload const [agree, setAgree] = useState(false); // preload
@ -38,6 +47,11 @@ function PrivacyAgreement(props: Props) {
setShareDataInternal(false); setShareDataInternal(false);
setShareDataThirdParty(false); setShareDataThirdParty(false);
} }
if (share === FREE || share === LIMITED) {
authenticateIfSharingData();
}
setWelcomeVersion(WELCOME_VERSION); setWelcomeVersion(WELCOME_VERSION);
history.replace(`/`); history.replace(`/`);
} }