lbry-desktop/ui/component/app/index.js

55 lines
2.3 KiB
JavaScript
Raw Normal View History

2019-03-05 07:24:03 +01:00
import { hot } from 'react-hot-loader/root';
import { connect } from 'react-redux';
import { selectGetSyncErrorMessage, selectUploadCount } from 'lbryinc';
import { doFetchAccessToken, doUserSetReferrer } from 'redux/actions/user';
import { selectUser, selectAccessToken, selectUserVerifiedEmail } from 'redux/selectors/user';
import { selectUnclaimedRewards } from 'redux/selectors/rewards';
import { doFetchChannelListMine, SETTINGS } from 'lbry-redux';
2020-09-04 17:02:30 +02:00
import {
makeSelectClientSetting,
selectLoadedLanguages,
selectSyncSigninPref,
selectThemePath,
} from 'redux/selectors/settings';
import { selectIsUpgradeAvailable, selectAutoUpdateDownloaded } from 'redux/selectors/app';
2020-09-04 17:02:30 +02:00
import { doSetLanguage, doUpdateSyncPref } from 'redux/actions/settings';
import { doSyncSubscribe } from 'redux/actions/syncwrapper';
2020-01-14 21:44:07 +01:00
import {
doDownloadUpgradeRequested,
doSignIn,
doGetAndPopulatePreferences,
doAnalyticsTagSync,
2020-01-14 21:44:07 +01:00
} from 'redux/actions/app';
import App from './view';
2017-04-07 07:15:22 +02:00
2018-03-26 23:32:43 +02:00
const select = state => ({
2017-07-28 03:13:12 +02:00
user: selectUser(state),
2020-01-14 21:44:07 +01:00
accessToken: selectAccessToken(state),
2018-10-19 17:27:14 +02:00
theme: selectThemePath(state),
language: makeSelectClientSetting(SETTINGS.LANGUAGE)(state),
2020-09-04 17:02:30 +02:00
syncEnabled: makeSelectClientSetting(SETTINGS.ENABLE_SYNC)(state),
2019-11-08 21:51:42 +01:00
languages: selectLoadedLanguages(state),
autoUpdateDownloaded: selectAutoUpdateDownloaded(state),
isUpgradeAvailable: selectIsUpgradeAvailable(state),
2019-10-22 19:57:32 +02:00
syncError: selectGetSyncErrorMessage(state),
uploadCount: selectUploadCount(state),
2020-01-14 21:44:07 +01:00
rewards: selectUnclaimedRewards(state),
isAuthenticated: selectUserVerifiedEmail(state),
2020-09-04 17:02:30 +02:00
signInSyncPref: selectSyncSigninPref(state),
2017-07-28 03:13:12 +02:00
});
2017-04-07 07:15:22 +02:00
2017-06-06 06:21:55 +02:00
const perform = dispatch => ({
analyticsTagSync: () => dispatch(doAnalyticsTagSync()),
2019-08-06 18:53:59 +02:00
fetchAccessToken: () => dispatch(doFetchAccessToken()),
fetchChannelListMine: () => dispatch(doFetchChannelListMine()),
2019-11-08 21:51:42 +01:00
setLanguage: language => dispatch(doSetLanguage(language)),
2019-10-01 06:53:33 +02:00
signIn: () => dispatch(doSignIn()),
requestDownloadUpgrade: () => dispatch(doDownloadUpgradeRequested()),
updatePreferences: () => dispatch(doGetAndPopulatePreferences()),
2020-09-04 17:02:30 +02:00
updateSyncPref: () => dispatch(doUpdateSyncPref()),
syncSubscribe: () => dispatch(doSyncSubscribe()),
2020-01-14 21:44:07 +01:00
setReferrer: (referrer, doClaim) => dispatch(doUserSetReferrer(referrer, doClaim)),
2017-06-06 06:21:55 +02:00
});
2017-04-07 07:15:22 +02:00
export default hot(connect(select, perform)(App));