lbry-desktop/ui/js/selectors/settings.js

40 lines
1,000 B
JavaScript
Raw Normal View History

2017-09-06 20:52:34 -04:00
import * as settings from "constants/settings";
2017-06-06 17:19:12 -04:00
import { createSelector } from "reselect";
2017-06-05 21:21:55 -07:00
const _selectState = state => state.settings || {};
export const selectDaemonSettings = createSelector(
_selectState,
state => state.daemonSettings
2017-06-05 21:21:55 -07:00
);
export const selectClientSettings = createSelector(
_selectState,
2017-06-28 14:12:01 +07:00
state => state.clientSettings || {}
2017-06-05 21:21:55 -07:00
);
2017-08-20 23:06:26 -04:00
export const makeSelectClientSetting = setting => {
return createSelector(
selectClientSettings,
settings => (settings ? settings[setting] : undefined)
);
};
export const selectSettingsIsGenerous = createSelector(
selectDaemonSettings,
2017-06-06 17:19:12 -04:00
settings => settings && settings.is_generous_host
2017-06-05 21:21:55 -07:00
);
2017-06-28 14:12:01 +07:00
2017-09-06 21:53:42 -04:00
//refactor me
export const selectShowNsfw = makeSelectClientSetting(settings.SHOW_NSFW);
2017-08-08 10:36:14 +01:00
2017-08-19 14:03:51 -04:00
export const selectLanguages = createSelector(
2017-08-08 10:36:14 +01:00
_selectState,
2017-08-19 14:03:51 -04:00
state => state.languages || {}
2017-08-08 10:36:14 +01:00
);
2017-09-06 20:52:34 -04:00
export const selectThemePath = createSelector(
makeSelectClientSetting(settings.THEME),
theme => "themes/" + (theme || "light") + ".css"
);