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

View file

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