lbry-desktop/ui/component/wunderbar/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

42 lines
1.4 KiB
JavaScript

import { connect } from 'react-redux';
import {
doFocusSearchInput,
doBlurSearchInput,
doUpdateSearchQuery,
selectSearchValue,
selectSearchSuggestions,
selectSearchBarFocused,
SETTINGS,
} from 'lbry-redux';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import { doToast } from 'redux/actions/notifications';
import analytics from 'analytics';
import Wunderbar from './view';
import { withRouter } from 'react-router-dom';
import { formatLbryUrlForWeb } from 'util/url';
const select = state => ({
suggestions: selectSearchSuggestions(state),
searchQuery: selectSearchValue(state),
isFocused: selectSearchBarFocused(state),
language: makeSelectClientSetting(SETTINGS.LANGUAGE)(state),
});
const perform = (dispatch, ownProps) => ({
onSearch: query => {
ownProps.history.push({ pathname: `/$/search`, search: `?q=${encodeURIComponent(query)}` });
dispatch(doUpdateSearchQuery(query));
analytics.apiLogSearch();
},
onSubmit: uri => {
const path = formatLbryUrlForWeb(uri);
ownProps.history.push(path);
dispatch(doUpdateSearchQuery(''));
},
updateSearchQuery: query => dispatch(doUpdateSearchQuery(query)),
doShowSnackBar: message => dispatch(doToast({ isError: true, message })),
doFocus: () => dispatch(doFocusSearchInput()),
doBlur: () => dispatch(doBlurSearchInput()),
});
export default withRouter(connect(select, perform)(Wunderbar));