lbry-desktop/ui/js/page/settings/index.js

46 lines
1.6 KiB
JavaScript
Raw Normal View History

2017-06-06 23:19:12 +02:00
import React from "react";
import { connect } from "react-redux";
2017-09-07 02:52:34 +02:00
import * as settings from "constants/settings";
2017-11-13 22:02:23 +01:00
import { doClearCache } from "redux/actions/app";
import {
doSetDaemonSetting,
doSetClientSetting,
doGetThemes,
doSetTheme,
2017-08-19 20:03:51 +02:00
doChangeLanguage,
2017-11-13 22:02:23 +01:00
} from "redux/actions/settings";
2017-08-08 11:36:14 +02:00
import {
2017-09-07 02:52:34 +02:00
makeSelectClientSetting,
2017-08-08 11:36:14 +02:00
selectDaemonSettings,
2017-08-19 20:03:51 +02:00
selectLanguages,
2017-11-13 22:02:23 +01:00
} from "redux/selectors/settings";
import { selectCurrentLanguage } from "redux/selectors/app";
2017-06-06 23:19:12 +02:00
import SettingsPage from "./view";
2017-06-06 06:21:55 +02:00
const select = state => ({
2017-06-06 23:19:12 +02:00
daemonSettings: selectDaemonSettings(state),
2017-09-07 03:53:42 +02:00
showNsfw: makeSelectClientSetting(settings.SHOW_NSFW)(state),
showUnavailable: makeSelectClientSetting(settings.SHOW_UNAVAILABLE)(state),
instantPurchaseEnabled: makeSelectClientSetting(
settings.INSTANT_PURCHASE_ENABLED
)(state),
instantPurchaseMax: makeSelectClientSetting(settings.INSTANT_PURCHASE_MAX)(
state
),
showUnavailable: makeSelectClientSetting(settings.SHOW_UNAVAILABLE)(state),
2017-09-07 03:53:42 +02:00
theme: makeSelectClientSetting(settings.THEME)(state),
themes: makeSelectClientSetting(settings.THEMES)(state),
2017-07-07 15:15:45 +02:00
language: selectCurrentLanguage(state),
2017-08-19 20:03:51 +02:00
languages: selectLanguages(state),
2017-06-06 06:21:55 +02:00
});
2017-06-06 06:21:55 +02:00
const perform = dispatch => ({
setDaemonSetting: (key, value) => dispatch(doSetDaemonSetting(key, value)),
clearCache: () => dispatch(doClearCache()),
2017-06-28 09:12:01 +02:00
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
2017-09-07 02:52:34 +02:00
getThemes: () => dispatch(doGetThemes()),
2017-08-08 11:36:14 +02:00
changeLanguage: newLanguage => dispatch(doChangeLanguage(newLanguage)),
2017-06-06 06:21:55 +02:00
});
2017-06-06 06:21:55 +02:00
export default connect(select, perform)(SettingsPage);