lbry-desktop/ui/js/selectors/settings.js
2017-09-06 21:53:42 -04:00

39 lines
1,000 B
JavaScript

import * as settings from "constants/settings";
import { createSelector } from "reselect";
const _selectState = state => state.settings || {};
export const selectDaemonSettings = createSelector(
_selectState,
state => state.daemonSettings
);
export const selectClientSettings = createSelector(
_selectState,
state => state.clientSettings || {}
);
export const makeSelectClientSetting = setting => {
return createSelector(
selectClientSettings,
settings => (settings ? settings[setting] : undefined)
);
};
export const selectSettingsIsGenerous = createSelector(
selectDaemonSettings,
settings => settings && settings.is_generous_host
);
//refactor me
export const selectShowNsfw = makeSelectClientSetting(settings.SHOW_NSFW);
export const selectLanguages = createSelector(
_selectState,
state => state.languages || {}
);
export const selectThemePath = createSelector(
makeSelectClientSetting(settings.THEME),
theme => "themes/" + (theme || "light") + ".css"
);