From 767630a98576122858bd4a270b9d9945a47fa372 Mon Sep 17 00:00:00 2001 From: Jeremy Kauffman Date: Fri, 22 Sep 2017 19:23:51 -0400 Subject: [PATCH] finally killed client settings in lbry.js --- ui/js/actions/content.js | 7 +++--- ui/js/actions/settings.js | 2 -- ui/js/lbry.js | 38 ------------------------------ ui/js/lighthouse.js | 4 +--- ui/js/page/developer.js | 47 -------------------------------------- ui/js/reducers/settings.js | 35 +++++++++++++++++++--------- 6 files changed, 29 insertions(+), 104 deletions(-) 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/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 index 970a0d3e7..34005b3e3 100644 --- a/ui/js/page/developer.js +++ b/ui/js/page/developer.js @@ -11,23 +11,10 @@ class DeveloperPage extends React.PureComponent { 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, @@ -60,40 +47,6 @@ class DeveloperPage extends React.PureComponent { render() { return (
-
-

{__("Developer Settings")}

-
- -
- {this.state.useCustomLighthouseServers - ?
- -
- : null} -