diff --git a/ui/js/actions/content.js b/ui/js/actions/content.js index 7a2c6dcaa..f377a131c 100644 --- a/ui/js/actions/content.js +++ b/ui/js/actions/content.js @@ -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 { diff --git a/ui/js/actions/settings.js b/ui/js/actions/settings.js index 4395c6603..79c098a95 100644 --- a/ui/js/actions/settings.js +++ b/ui/js/actions/settings.js @@ -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: { diff --git a/ui/js/component/router/view.jsx b/ui/js/component/router/view.jsx index 57f9630c2..ed3c5f7bf 100644 --- a/ui/js/component/router/view.jsx +++ b/ui/js/component/router/view.jsx @@ -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: , backup: , channel: , - developer: , discover: , downloaded: , help: , diff --git a/ui/js/lbry.js b/ui/js/lbry.js index 9f9dc0e51..36f221afb 100644 --- a/ui/js/lbry.js +++ b/ui/js/lbry.js @@ -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; }; diff --git a/ui/js/lighthouse.js b/ui/js/lighthouse.js index d7052a0ee..32b748114 100644 --- a/ui/js/lighthouse.js +++ b/ui/js/lighthouse.js @@ -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) { diff --git a/ui/js/page/developer.js b/ui/js/page/developer.js deleted file mode 100644 index 970a0d3e7..000000000 --- a/ui/js/page/developer.js +++ /dev/null @@ -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 ( -
-
-

{__("Developer Settings")}

-
- -
- {this.state.useCustomLighthouseServers - ?
- -
- : null} -
-
-
- { - this.handleUpgradeFileChange(); - }} - /> -   - { - this.handleForceUpgradeClick(); - }} - /> -
-
-
- ); - } -} - -export default DeveloperPage; diff --git a/ui/js/page/rewards/view.jsx b/ui/js/page/rewards/view.jsx index 9f421b76d..97344d152 100644 --- a/ui/js/page/rewards/view.jsx +++ b/ui/js/page/rewards/view.jsx @@ -114,7 +114,7 @@ class RewardsPage extends React.PureComponent { } else if (!rewards || rewards.length <= 0) { return (
- {__("Failed to load rewards.")} + {__("There are no rewards available at this time, please check back later.")}
); } else { diff --git a/ui/js/reducers/settings.js b/ui/js/reducers/settings.js index 1c6834a91..784b6aa8f 100644 --- a/ui/js/reducers/settings.js +++ b/ui/js/reducers/settings.js @@ -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, }); diff --git a/ui/scss/all.scss b/ui/scss/all.scss index 458493d81..f5aa9b3c1 100644 --- a/ui/scss/all.scss +++ b/ui/scss/all.scss @@ -24,5 +24,4 @@ @import "component/_scrollbar.scss"; @import "component/_tabs.scss"; @import "component/_media.scss"; -@import "page/_developer.scss"; @import "page/_show.scss"; diff --git a/ui/scss/page/_developer.scss b/ui/scss/page/_developer.scss deleted file mode 100644 index 1a3a118d6..000000000 --- a/ui/scss/page/_developer.scss +++ /dev/null @@ -1,5 +0,0 @@ -.developer-page__custom-lighthouse-servers { - font: 0.8em monospace; - width: 30em; - height: 10em; -} \ No newline at end of file