lbry-desktop/ui/page/settings/index.js
infiinte-persistence 7839bbf2a1 Fix language-change not applied to all components immediately.
## Fixes:
3641 Language switch does not take effect right away

## Assessment:
Although `Card`s in the Settings Page are actually being re-rendered, the `actions` within them might not be getting the signal, depending on their props.

## Changes:
(1) Pass the language variable to the `actions`'s props for items that are affected.
(2) Make the Wunderbar listen to language-changes as well (the only component outside of Settings that would need an immediate update).
2020-06-29 09:48:12 -04:00

69 lines
3 KiB
JavaScript

import { connect } from 'react-redux';
import {
doClearCache,
doNotifyEncryptWallet,
doNotifyDecryptWallet,
doNotifyForgetPassword,
doToggle3PAnalytics,
doOpenModal,
} from 'redux/actions/app';
import { selectAllowAnalytics } from 'redux/selectors/app';
import {
doSetDaemonSetting,
doClearDaemonSetting,
doSetClientSetting,
doSetDarkTime,
doFindFFmpeg,
} from 'redux/actions/settings';
import { doSetPlayingUri } from 'redux/actions/content';
import {
makeSelectClientSetting,
selectDaemonSettings,
selectFfmpegStatus,
selectFindingFFmpeg,
} from 'redux/selectors/settings';
import { doWalletStatus, selectWalletIsEncrypted, selectBlockedChannelsCount, SETTINGS } from 'lbry-redux';
import SettingsPage from './view';
import { selectUserVerifiedEmail } from 'redux/selectors/user';
const select = state => ({
daemonSettings: selectDaemonSettings(state),
allowAnalytics: selectAllowAnalytics(state),
isAuthenticated: selectUserVerifiedEmail(state),
showNsfw: makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state),
instantPurchaseEnabled: makeSelectClientSetting(SETTINGS.INSTANT_PURCHASE_ENABLED)(state),
instantPurchaseMax: makeSelectClientSetting(SETTINGS.INSTANT_PURCHASE_MAX)(state),
currentTheme: makeSelectClientSetting(SETTINGS.THEME)(state),
themes: makeSelectClientSetting(SETTINGS.THEMES)(state),
automaticDarkModeEnabled: makeSelectClientSetting(SETTINGS.AUTOMATIC_DARK_MODE_ENABLED)(state),
autoplay: makeSelectClientSetting(SETTINGS.AUTOPLAY)(state),
walletEncrypted: selectWalletIsEncrypted(state),
autoDownload: makeSelectClientSetting(SETTINGS.AUTO_DOWNLOAD)(state),
userBlockedChannelsCount: selectBlockedChannelsCount(state),
hideBalance: makeSelectClientSetting(SETTINGS.HIDE_BALANCE)(state),
floatingPlayer: makeSelectClientSetting(SETTINGS.FLOATING_PLAYER)(state),
hideReposts: makeSelectClientSetting(SETTINGS.HIDE_REPOSTS)(state),
darkModeTimes: makeSelectClientSetting(SETTINGS.DARK_MODE_TIMES)(state),
ffmpegStatus: selectFfmpegStatus(state),
findingFFmpeg: selectFindingFFmpeg(state),
language: makeSelectClientSetting(SETTINGS.LANGUAGE)(state),
});
const perform = dispatch => ({
setDaemonSetting: (key, value) => dispatch(doSetDaemonSetting(key, value)),
clearDaemonSetting: key => dispatch(doClearDaemonSetting(key)),
toggle3PAnalytics: allow => dispatch(doToggle3PAnalytics(allow)),
clearCache: () => dispatch(doClearCache()),
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
encryptWallet: () => dispatch(doNotifyEncryptWallet()),
decryptWallet: () => dispatch(doNotifyDecryptWallet()),
updateWalletStatus: () => dispatch(doWalletStatus()),
confirmForgetPassword: modalProps => dispatch(doNotifyForgetPassword(modalProps)),
clearPlayingUri: () => dispatch(doSetPlayingUri(null)),
setDarkTime: (time, options) => dispatch(doSetDarkTime(time, options)),
findFFmpeg: () => dispatch(doFindFFmpeg()),
openModal: (id, params) => dispatch(doOpenModal(id, params)),
});
export default connect(select, perform)(SettingsPage);