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