lbry-desktop/ui/redux/selectors/settings.js
jessop 3b23f09bed fix sync clean wallet bug
remove previous changes,keep syncpref in wallet, change anon wallet pref key to local

sync choices wip

dont relocate syncenable setting

bump

no prefs on web unauth

bugfix redux bump

pull after sync change

bump
2020-09-21 14:11:25 -04:00

55 lines
2.2 KiB
JavaScript

import { SETTINGS, DAEMON_SETTINGS } from 'lbry-redux';
import { createSelector } from 'reselect';
const selectState = state => state.settings || {};
export const selectDaemonSettings = createSelector(selectState, state => state.daemonSettings);
export const selectDaemonStatus = createSelector(selectState, state => state.daemonStatus);
export const selectFfmpegStatus = createSelector(selectDaemonStatus, status => status.ffmpeg_status);
export const selectFindingFFmpeg = createSelector(selectState, state => state.findingFFmpeg || false);
export const selectClientSettings = createSelector(selectState, state => state.clientSettings || {});
export const selectLoadedLanguages = createSelector(selectState, state => state.loadedLanguages || {});
export const makeSelectClientSetting = setting =>
createSelector(selectClientSettings, settings => (settings ? settings[setting] : undefined));
// refactor me
export const selectShowMatureContent = makeSelectClientSetting(SETTINGS.SHOW_MATURE);
// and me
export const selectShowRepostedContent = makeSelectClientSetting(SETTINGS.HIDE_REPOSTS);
export const selectTheme = makeSelectClientSetting(SETTINGS.THEME);
export const selectAutomaticDarkModeEnabled = makeSelectClientSetting(SETTINGS.AUTOMATIC_DARK_MODE_ENABLED);
export const selectIsNight = createSelector(selectState, state => state.isNight);
export const selectSavedWalletServers = createSelector(selectState, state => state.customWalletServers);
export const selectSharedPreferences = createSelector(selectState, state => state.sharedPreferences);
export const makeSelectSharedPreferencesForKey = key =>
createSelector(selectSharedPreferences, prefs => (prefs ? prefs[key] : undefined));
export const selectHasWalletServerPrefs = createSelector(
makeSelectSharedPreferencesForKey(DAEMON_SETTINGS.LBRYUM_SERVERS),
servers => {
return !!(servers && servers.length);
}
);
export const selectThemePath = createSelector(
selectTheme,
selectAutomaticDarkModeEnabled,
selectIsNight,
(theme, automaticDarkModeEnabled, isNight) => {
const dynamicTheme = automaticDarkModeEnabled && isNight ? 'dark' : theme;
return dynamicTheme || 'light';
}
);
export const selectosNotificationsEnabled = makeSelectClientSetting(SETTINGS.OS_NOTIFICATIONS_ENABLED);