Merge branch 'master' into css_patch
This commit is contained in:
commit
ac2a69c47d
10 changed files with 31 additions and 188 deletions
|
@ -3,6 +3,7 @@ import * as settings from "constants/settings";
|
|||
import lbry from "lbry";
|
||||
import lbryio from "lbryio";
|
||||
import lbryuri from "lbryuri";
|
||||
import { makeSelectClientSetting } from "selectors/settings";
|
||||
import { selectBalance } from "selectors/wallet";
|
||||
import {
|
||||
makeSelectFileInfoForUri,
|
||||
|
@ -360,13 +361,13 @@ export function doPurchaseUri(uri) {
|
|||
|
||||
if (
|
||||
cost == 0 ||
|
||||
!lbry.getClientSetting(settings.INSTANT_PURCHASE_ENABLED)
|
||||
!makeSelectClientSetting(settings.INSTANT_PURCHASE_ENABLED)(state)
|
||||
) {
|
||||
attemptPlay(cost);
|
||||
} else {
|
||||
const instantPurchaseMax = lbry.getClientSetting(
|
||||
const instantPurchaseMax = makeSelectClientSetting(
|
||||
settings.INSTANT_PURCHASE_MAX
|
||||
);
|
||||
)(state);
|
||||
if (instantPurchaseMax.currency == "LBC") {
|
||||
attemptPlay(cost, instantPurchaseMax.amount);
|
||||
} else {
|
||||
|
|
|
@ -41,8 +41,6 @@ export function doSetDaemonSetting(key, value) {
|
|||
}
|
||||
|
||||
export function doSetClientSetting(key, value) {
|
||||
lbry.setClientSetting(key, value);
|
||||
|
||||
return {
|
||||
type: types.CLIENT_SETTING_CHANGED,
|
||||
data: {
|
||||
|
|
|
@ -8,7 +8,6 @@ import SendCreditsPage from "page/sendCredits";
|
|||
import ShowPage from "page/show";
|
||||
import PublishPage from "page/publish";
|
||||
import DiscoverPage from "page/discover";
|
||||
import DeveloperPage from "page/developer.js";
|
||||
import RewardsPage from "page/rewards";
|
||||
import FileListDownloaded from "page/fileListDownloaded";
|
||||
import FileListPublished from "page/fileListPublished";
|
||||
|
@ -32,7 +31,6 @@ const Router = props => {
|
|||
auth: <AuthPage params={params} />,
|
||||
backup: <BackupPage params={params} />,
|
||||
channel: <ChannelPage params={params} />,
|
||||
developer: <DeveloperPage params={params} />,
|
||||
discover: <DiscoverPage params={params} />,
|
||||
downloaded: <FileListDownloaded params={params} />,
|
||||
help: <HelpPage params={params} />,
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
import lighthouse from "./lighthouse.js";
|
||||
import jsonrpc from "./jsonrpc.js";
|
||||
import lbryuri from "./lbryuri.js";
|
||||
|
||||
/**
|
||||
* The 4 get/set functions below used to be in a utils.js library when used more widely.
|
||||
* They've been reduced to just this file and probably ought to be eliminated entirely.
|
||||
*/
|
||||
function getLocal(key, fallback = undefined) {
|
||||
const itemRaw = localStorage.getItem(key);
|
||||
return itemRaw === null ? fallback : JSON.parse(itemRaw);
|
||||
|
@ -15,15 +10,6 @@ function setLocal(key, value) {
|
|||
localStorage.setItem(key, JSON.stringify(value));
|
||||
}
|
||||
|
||||
function getSession(key, fallback = undefined) {
|
||||
const itemRaw = sessionStorage.getItem(key);
|
||||
return itemRaw === null ? fallback : JSON.parse(itemRaw);
|
||||
}
|
||||
|
||||
function setSession(key, value) {
|
||||
sessionStorage.setItem(key, JSON.stringify(value));
|
||||
}
|
||||
|
||||
const { remote, ipcRenderer } = require("electron");
|
||||
const menu = remote.require("./menu/main-menu");
|
||||
|
||||
|
@ -31,19 +17,6 @@ let lbry = {
|
|||
isConnected: false,
|
||||
daemonConnectionString: "http://localhost:5279",
|
||||
pendingPublishTimeout: 20 * 60 * 1000,
|
||||
defaultClientSettings: {
|
||||
showNsfw: false,
|
||||
showUnavailable: true,
|
||||
debug: false,
|
||||
useCustomLighthouseServers: false,
|
||||
customLighthouseServers: [],
|
||||
language: "en",
|
||||
theme: "light",
|
||||
themes: [],
|
||||
instantPurchaseMax: null,
|
||||
instantPurchaseEnabled: false,
|
||||
instantPurchaseMax: { currency: "LBC", amount: 0.1 },
|
||||
},
|
||||
};
|
||||
|
||||
function apiCall(method, params, resolve, reject) {
|
||||
|
@ -227,17 +200,6 @@ lbry.publishDeprecated = function(
|
|||
);
|
||||
};
|
||||
|
||||
lbry.getClientSetting = function(setting) {
|
||||
var localStorageVal = localStorage.getItem("setting_" + setting);
|
||||
return localStorageVal === null
|
||||
? lbry.defaultClientSettings[setting]
|
||||
: JSON.parse(localStorageVal);
|
||||
};
|
||||
|
||||
lbry.setClientSetting = function(setting, value) {
|
||||
return localStorage.setItem("setting_" + setting, JSON.stringify(value));
|
||||
};
|
||||
|
||||
lbry.imagePath = function(file) {
|
||||
return "img/" + file;
|
||||
};
|
||||
|
|
|
@ -14,9 +14,7 @@ let server = null;
|
|||
let connectTryNum = 0;
|
||||
|
||||
function getServers() {
|
||||
return lbry.getClientSetting("useCustomLighthouseServers")
|
||||
? lbry.getClientSetting("customLighthouseServers")
|
||||
: defaultServers;
|
||||
return defaultServers;
|
||||
}
|
||||
|
||||
function call(method, params, callback, errorCallback) {
|
||||
|
|
|
@ -1,122 +0,0 @@
|
|||
import lbry from "../lbry.js";
|
||||
import React from "react";
|
||||
import FormField from "component/formField";
|
||||
import Link from "../component/link";
|
||||
|
||||
const fs = require("fs");
|
||||
const { ipcRenderer } = require("electron");
|
||||
|
||||
class DeveloperPage extends React.PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
useCustomLighthouseServers: lbry.getClientSetting(
|
||||
"useCustomLighthouseServers"
|
||||
),
|
||||
customLighthouseServers: lbry
|
||||
.getClientSetting("customLighthouseServers")
|
||||
.join("\n"),
|
||||
upgradePath: "",
|
||||
};
|
||||
}
|
||||
|
||||
handleUseCustomLighthouseServersChange(event) {
|
||||
lbry.setClientSetting("useCustomLighthouseServers", event.target.checked);
|
||||
this.setState({
|
||||
useCustomLighthouseServers: event.target.checked,
|
||||
});
|
||||
}
|
||||
|
||||
handleUpgradeFileChange(event) {
|
||||
this.setState({
|
||||
upgradePath: event.target.value,
|
||||
});
|
||||
}
|
||||
|
||||
handleForceUpgradeClick() {
|
||||
let upgradeSent = false;
|
||||
if (!this.state.upgradePath) {
|
||||
alert(__("Please select a file to upgrade from"));
|
||||
} else {
|
||||
try {
|
||||
const stats = fs.lstatSync(this.state.upgradePath);
|
||||
if (stats.isFile()) {
|
||||
console.log("Starting upgrade using " + this.state.upgradePath);
|
||||
ipcRenderer.send("upgrade", this.state.upgradePath);
|
||||
upgradeSent = true;
|
||||
}
|
||||
} catch (e) {}
|
||||
if (!upgradeSent) {
|
||||
alert(
|
||||
'Failed to start upgrade. Is "' +
|
||||
this.state.upgradePath +
|
||||
'" a valid path to the upgrade?'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<main>
|
||||
<section className="card">
|
||||
<h3>{__("Developer Settings")}</h3>
|
||||
<div className="form-row">
|
||||
<label>
|
||||
<FormField
|
||||
type="checkbox"
|
||||
onChange={event => {
|
||||
this.handleUseCustomLighthouseServersChange();
|
||||
}}
|
||||
checked={this.state.useCustomLighthouseServers}
|
||||
/>
|
||||
{" "}
|
||||
{__("Use custom search servers")}
|
||||
</label>
|
||||
</div>
|
||||
{this.state.useCustomLighthouseServers
|
||||
? <div className="form-row">
|
||||
<label>
|
||||
{__("Custom search servers (one per line)")}
|
||||
<div>
|
||||
<FormField
|
||||
type="textarea"
|
||||
className="developer-page__custom-lighthouse-servers"
|
||||
value={this.state.customLighthouseServers}
|
||||
onChange={event => {
|
||||
this.handleCustomLighthouseServersChange();
|
||||
}}
|
||||
checked={this.state.debugMode}
|
||||
/>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
: null}
|
||||
</section>
|
||||
<section className="card">
|
||||
<div className="form-row">
|
||||
<FormField
|
||||
name="file"
|
||||
ref="file"
|
||||
type="file"
|
||||
onChange={event => {
|
||||
this.handleUpgradeFileChange();
|
||||
}}
|
||||
/>
|
||||
|
||||
<Link
|
||||
label={__("Force Upgrade")}
|
||||
button="alt"
|
||||
onClick={event => {
|
||||
this.handleForceUpgradeClick();
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default DeveloperPage;
|
|
@ -114,7 +114,7 @@ class RewardsPage extends React.PureComponent {
|
|||
} else if (!rewards || rewards.length <= 0) {
|
||||
return (
|
||||
<div className="card__content empty">
|
||||
{__("Failed to load rewards.")}
|
||||
{__("There are no rewards available at this time, please check back later.")}
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
|
|
|
@ -1,24 +1,35 @@
|
|||
import * as types from "constants/action_types";
|
||||
import * as settings from "constants/settings";
|
||||
import LANGUAGES from "constants/languages";
|
||||
import lbry from "lbry";
|
||||
|
||||
function getLocalStorageSetting(setting, fallback) {
|
||||
var localStorageVal = localStorage.getItem("setting_" + setting);
|
||||
return localStorageVal === null ? fallback : JSON.parse(localStorageVal);
|
||||
}
|
||||
|
||||
const reducers = {};
|
||||
const defaultState = {
|
||||
clientSettings: {
|
||||
instantPurchaseEnabled: lbry.getClientSetting(
|
||||
settings.INSTANT_PURCHASE_ENABLED
|
||||
instantPurchaseEnabled: getLocalStorageSetting(
|
||||
settings.INSTANT_PURCHASE_ENABLED,
|
||||
false
|
||||
),
|
||||
instantPurchaseMax: lbry.getClientSetting(settings.INSTANT_PURCHASE_MAX),
|
||||
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(
|
||||
instantPurchaseMax: getLocalStorageSetting(settings.INSTANT_PURCHASE_MAX, {
|
||||
currency: "LBC",
|
||||
amount: 0.1,
|
||||
}),
|
||||
showNsfw: getLocalStorageSetting(settings.SHOW_NSFW, false),
|
||||
showUnavailable: getLocalStorageSetting(settings.SHOW_UNAVAILABLE, true),
|
||||
welcome_acknowledged: getLocalStorageSetting(
|
||||
settings.NEW_USER_ACKNOWLEDGED,
|
||||
false
|
||||
),
|
||||
credit_intro_acknowledged: getLocalStorageSetting(
|
||||
settings.CREDIT_INTRO_ACKNOWLEDGED
|
||||
),
|
||||
language: lbry.getClientSetting(settings.LANGUAGE),
|
||||
theme: lbry.getClientSetting(settings.THEME),
|
||||
themes: lbry.getClientSetting(settings.THEMES),
|
||||
language: getLocalStorageSetting(settings.LANGUAGE, "en"),
|
||||
theme: getLocalStorageSetting(settings.THEME, "light"),
|
||||
themes: getLocalStorageSetting(settings.THEMES, []),
|
||||
},
|
||||
languages: {},
|
||||
};
|
||||
|
@ -35,6 +46,9 @@ reducers[types.CLIENT_SETTING_CHANGED] = function(state, action) {
|
|||
|
||||
clientSettings[key] = value;
|
||||
|
||||
//this technically probably shouldn't happen here, and should be fixed when we're no longer using localStorage at all for persistent app state
|
||||
localStorage.setItem("setting_" + key, JSON.stringify(value));
|
||||
|
||||
return Object.assign({}, state, {
|
||||
clientSettings,
|
||||
});
|
||||
|
|
|
@ -24,5 +24,4 @@
|
|||
@import "component/_scrollbar.scss";
|
||||
@import "component/_tabs.scss";
|
||||
@import "component/_media.scss";
|
||||
@import "page/_developer.scss";
|
||||
@import "page/_show.scss";
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
.developer-page__custom-lighthouse-servers {
|
||||
font: 0.8em monospace;
|
||||
width: 30em;
|
||||
height: 10em;
|
||||
}
|
Loading…
Reference in a new issue