more settings progress
This commit is contained in:
parent
ad6b4f4f03
commit
4cc9f46934
8 changed files with 30 additions and 47 deletions
|
@ -164,7 +164,7 @@ export function doDownloadLanguages() {
|
|||
|
||||
export function doChangeLanguage(language) {
|
||||
return function(dispatch, getState) {
|
||||
lbry.setClientSetting(settings.LANGUAGE, language);
|
||||
dispatch(doSetClientSetting(settings.LANGUAGE, language));
|
||||
app.i18n.setLocale(language);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,18 +1,13 @@
|
|||
import store from "store.js";
|
||||
import lbry from "./lbry.js";
|
||||
import * as settings from "constants/settings";
|
||||
|
||||
const env = ENV;
|
||||
const config = {
|
||||
...require(`./config/${env}`),
|
||||
};
|
||||
const language = lbry.getClientSetting(settings.LANGUAGE)
|
||||
? lbry.getClientSetting(settings.LANGUAGE)
|
||||
: "en";
|
||||
const i18n = require("y18n")({
|
||||
directory: "app/locales",
|
||||
updateFiles: false,
|
||||
locale: language,
|
||||
locale: "en",
|
||||
});
|
||||
const logs = [];
|
||||
const app = {
|
||||
|
|
|
@ -9,7 +9,6 @@ const Theme = props => {
|
|||
|
||||
return (
|
||||
<link
|
||||
id="theme"
|
||||
href={themePath}
|
||||
rel="stylesheet"
|
||||
type="text/css"
|
||||
|
|
|
@ -279,17 +279,6 @@ lbry.publishDeprecated = function(
|
|||
);
|
||||
};
|
||||
|
||||
lbry.getClientSettings = function() {
|
||||
var outSettings = {};
|
||||
for (let setting of Object.keys(lbry.defaultClientSettings)) {
|
||||
var localStorageVal = localStorage.getItem("setting_" + setting);
|
||||
outSettings[setting] = localStorageVal === null
|
||||
? lbry.defaultClientSettings[setting]
|
||||
: JSON.parse(localStorageVal);
|
||||
}
|
||||
return outSettings;
|
||||
};
|
||||
|
||||
lbry.getClientSetting = function(setting) {
|
||||
var localStorageVal = localStorage.getItem("setting_" + setting);
|
||||
if (setting == "showDeveloperMenu") {
|
||||
|
@ -300,12 +289,6 @@ lbry.getClientSetting = function(setting) {
|
|||
: JSON.parse(localStorageVal);
|
||||
};
|
||||
|
||||
lbry.setClientSettings = function(settings) {
|
||||
for (let setting of Object.keys(settings)) {
|
||||
lbry.setClientSetting(setting, settings[setting]);
|
||||
}
|
||||
};
|
||||
|
||||
lbry.setClientSetting = function(setting, value) {
|
||||
return localStorage.setItem("setting_" + setting, JSON.stringify(value));
|
||||
};
|
||||
|
|
|
@ -12,7 +12,6 @@ import {
|
|||
import {
|
||||
makeSelectClientSetting,
|
||||
selectDaemonSettings,
|
||||
selectShowNsfw,
|
||||
selectLanguages,
|
||||
} from "selectors/settings";
|
||||
import { selectCurrentLanguage } from "selectors/app";
|
||||
|
@ -20,10 +19,12 @@ import SettingsPage from "./view";
|
|||
|
||||
const select = state => ({
|
||||
daemonSettings: selectDaemonSettings(state),
|
||||
showNsfw: selectShowNsfw(state),
|
||||
showNsfw: makeSelectClientSetting(settings.SHOW_NSFW)(state),
|
||||
showUnavailable: makeSelectClientSetting(settings.SHOW_UNAVAILABLE)(state),
|
||||
theme: makeSelectClientSetting(settings.THEME)(state),
|
||||
themes: makeSelectClientSetting(settings.THEMES)(state),
|
||||
language: selectCurrentLanguage(state),
|
||||
languages: selectLanguages(state),
|
||||
theme: makeSelectClientSetting(settings.THEME)(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
|
|
|
@ -12,16 +12,8 @@ class SettingsPage extends React.PureComponent {
|
|||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
const { daemonSettings } = this.props || {};
|
||||
|
||||
this.state = {
|
||||
// isMaxUpload: daemonSettings && daemonSettings.max_upload != 0,
|
||||
// isMaxDownload: daemonSettings && daemonSettings.max_download != 0,
|
||||
showUnavailable: lbry.getClientSetting(settings.SHOW_UNAVAILABLE),
|
||||
language: lbry.getClientSetting(settings.LANGUAGE),
|
||||
clearingCache: false,
|
||||
theme: lbry.getClientSetting(settings.THEME),
|
||||
themes: lbry.getClientSetting(settings.THEMES),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -102,7 +94,12 @@ class SettingsPage extends React.PureComponent {
|
|||
this.forceUpdate();
|
||||
}
|
||||
|
||||
onShowUnavailableChange(event) {}
|
||||
onShowUnavailableChange(event) {
|
||||
this.props.setClientSetting(
|
||||
settings.SHOW_UNAVAILABLE,
|
||||
event.target.checked
|
||||
);
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
this.props.getThemes();
|
||||
|
@ -111,7 +108,15 @@ class SettingsPage extends React.PureComponent {
|
|||
componentDidMount() {}
|
||||
|
||||
render() {
|
||||
const { daemonSettings, language, languages, theme } = this.props;
|
||||
const {
|
||||
daemonSettings,
|
||||
language,
|
||||
languages,
|
||||
showNsfw,
|
||||
showUnavailable,
|
||||
theme,
|
||||
themes,
|
||||
} = this.props;
|
||||
|
||||
if (!daemonSettings || Object.keys(daemonSettings).length === 0) {
|
||||
return (
|
||||
|
@ -216,7 +221,7 @@ class SettingsPage extends React.PureComponent {
|
|||
<FormRow
|
||||
type="checkbox"
|
||||
onChange={this.onShowUnavailableChange.bind(this)}
|
||||
defaultChecked={this.state.showUnavailable}
|
||||
defaultChecked={showUnavailable}
|
||||
label={__("Show unavailable content in search results")}
|
||||
/>
|
||||
</div>
|
||||
|
@ -225,7 +230,7 @@ class SettingsPage extends React.PureComponent {
|
|||
label={__("Show NSFW content")}
|
||||
type="checkbox"
|
||||
onChange={this.onShowNsfwChange.bind(this)}
|
||||
defaultChecked={this.props.showNsfw}
|
||||
defaultChecked={showNsfw}
|
||||
helper={__(
|
||||
"NSFW content may include nudity, intense sexuality, profanity, or other adult content. By displaying NSFW content, you are affirming you are of legal age to view mature content in your country or jurisdiction. "
|
||||
)}
|
||||
|
@ -254,13 +259,14 @@ class SettingsPage extends React.PureComponent {
|
|||
<h3>{__("Theme")}</h3>
|
||||
</div>
|
||||
<div className="card__content">
|
||||
{console.log(theme)}
|
||||
<FormField
|
||||
type="select"
|
||||
onChange={this.onThemeChange.bind(this)}
|
||||
value={theme}
|
||||
defaultValue={theme}
|
||||
className="form-field__input--inline"
|
||||
>
|
||||
{this.state.themes.map((theme, index) =>
|
||||
{themes.map((theme, index) =>
|
||||
<option key={theme} value={theme}>
|
||||
{theme}
|
||||
</option>
|
||||
|
|
|
@ -6,7 +6,8 @@ import lbry from "lbry";
|
|||
const reducers = {};
|
||||
const defaultState = {
|
||||
clientSettings: {
|
||||
showNsfw: lbry.getClientSetting("showNsfw"),
|
||||
showNsfw: lbry.getClientSetting(settings.SHOW_NSFW),
|
||||
showUnavailable: lbry.getClientSetting(settings.SHOW_UNAVAILABLE),
|
||||
welcome_acknowledged: lbry.getClientSetting(settings.NEW_USER_ACKNOWLEDGED),
|
||||
credit_intro_acknowledged: lbry.getClientSetting(
|
||||
settings.CREDIT_INTRO_ACKNOWLEDGED
|
||||
|
|
|
@ -25,10 +25,8 @@ export const selectSettingsIsGenerous = createSelector(
|
|||
settings => settings && settings.is_generous_host
|
||||
);
|
||||
|
||||
export const selectShowNsfw = createSelector(
|
||||
selectClientSettings,
|
||||
clientSettings => !!clientSettings.showNsfw
|
||||
);
|
||||
//refactor me
|
||||
export const selectShowNsfw = makeSelectClientSetting(settings.SHOW_NSFW);
|
||||
|
||||
export const selectLanguages = createSelector(
|
||||
_selectState,
|
||||
|
|
Loading…
Reference in a new issue