2021-10-17 10:36:14 +02:00
|
|
|
import * as SETTINGS from 'constants/settings';
|
2020-09-11 20:35:50 +02:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
|
|
|
import {
|
|
|
|
selectGetSyncErrorMessage,
|
|
|
|
selectHasSyncedWallet,
|
|
|
|
selectGetSyncIsPending,
|
|
|
|
selectHashChanged,
|
2020-10-02 17:03:25 +02:00
|
|
|
} from 'redux/selectors/sync';
|
|
|
|
import { doCheckSync, doGetSync } from 'redux/actions/sync';
|
2022-02-26 06:18:10 +01:00
|
|
|
import { selectClientSetting } from 'redux/selectors/settings';
|
2020-09-11 20:35:50 +02:00
|
|
|
import { doSetWalletSyncPreference } from 'redux/actions/settings';
|
|
|
|
import SyncToggle from './view';
|
|
|
|
import { doGetAndPopulatePreferences } from 'redux/actions/app';
|
|
|
|
|
2021-10-17 10:36:14 +02:00
|
|
|
const select = (state) => ({
|
2021-11-23 05:29:04 +01:00
|
|
|
syncEnabled: selectClientSetting(state, SETTINGS.ENABLE_SYNC),
|
2020-09-11 20:35:50 +02:00
|
|
|
hasSyncedWallet: selectHasSyncedWallet(state),
|
|
|
|
hasSyncChanged: selectHashChanged(state),
|
|
|
|
verifiedEmail: selectUserVerifiedEmail(state),
|
|
|
|
getSyncError: selectGetSyncErrorMessage(state),
|
|
|
|
getSyncPending: selectGetSyncIsPending(state),
|
|
|
|
});
|
|
|
|
|
2021-10-17 10:36:14 +02:00
|
|
|
const perform = (dispatch) => ({
|
|
|
|
setSyncEnabled: (value) => dispatch(doSetWalletSyncPreference(value)),
|
2020-09-11 20:35:50 +02:00
|
|
|
checkSync: () => dispatch(doCheckSync()),
|
|
|
|
getSync: (pw, cb) => dispatch(doGetSync(pw, cb)),
|
|
|
|
updatePreferences: () => dispatch(doGetAndPopulatePreferences()),
|
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(select, perform)(SyncToggle);
|