review changes
This commit is contained in:
parent
f197236466
commit
3c739719b4
15 changed files with 161 additions and 144 deletions
|
@ -127,7 +127,7 @@
|
||||||
"imagesloaded": "^4.1.4",
|
"imagesloaded": "^4.1.4",
|
||||||
"json-loader": "^0.5.4",
|
"json-loader": "^0.5.4",
|
||||||
"lbry-format": "https://github.com/lbryio/lbry-format.git",
|
"lbry-format": "https://github.com/lbryio/lbry-format.git",
|
||||||
"lbry-redux": "lbryio/lbry-redux#7d2e8ba1707100393975897a70a28a63b288bc47",
|
"lbry-redux": "lbryio/lbry-redux#341d60661468b654b9baf5b96ca4a08ee202f0f2",
|
||||||
"lbryinc": "lbryio/lbryinc#1e897d2c9108848637e1915700d3ae8ce176f9f8",
|
"lbryinc": "lbryio/lbryinc#1e897d2c9108848637e1915700d3ae8ce176f9f8",
|
||||||
"lint-staged": "^7.0.2",
|
"lint-staged": "^7.0.2",
|
||||||
"localforage": "^1.7.1",
|
"localforage": "^1.7.1",
|
||||||
|
|
|
@ -935,5 +935,9 @@
|
||||||
"%numberOfMonthsSincePublish% months ago": "%numberOfMonthsSincePublish% months ago",
|
"%numberOfMonthsSincePublish% months ago": "%numberOfMonthsSincePublish% months ago",
|
||||||
"%numberOfDaysSincePublish% months ago": "%numberOfDaysSincePublish% months ago",
|
"%numberOfDaysSincePublish% months ago": "%numberOfDaysSincePublish% months ago",
|
||||||
"%numberOfDaysSincePublish% days ago": "%numberOfDaysSincePublish% days ago",
|
"%numberOfDaysSincePublish% days ago": "%numberOfDaysSincePublish% days ago",
|
||||||
"The wallet server took a bit too long. Resetting defaults just in case. Shutdown (Cmd/Ctrl+Q) LBRY and restart if this continues.": "The wallet server took a bit too long. Resetting defaults just in case. Shutdown (Cmd/Ctrl+Q) LBRY and restart if this continues."
|
"The wallet server took a bit too long. Resetting defaults just in case. Shutdown (Cmd/Ctrl+Q) LBRY and restart if this continues.": "The wallet server took a bit too long. Resetting defaults just in case. Shutdown (Cmd/Ctrl+Q) LBRY and restart if this continues.",
|
||||||
|
"Provide a description and link to your license": "Provide a description and link to your license",
|
||||||
|
"Walletserver preference": "Walletserver preference",
|
||||||
|
"Wallet servers": "Wallet servers",
|
||||||
|
"lbry.tv": "lbry.tv"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,21 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { DAEMON_SETTINGS } from 'lbry-redux';
|
import { DAEMON_SETTINGS } from 'lbry-redux';
|
||||||
import { doSetDaemonSetting, doClearDaemonSetting, doGetDaemonStatus, doCacheCustomWalletServers, doFetchDaemonSettings } from 'redux/actions/settings';
|
import { doSetDaemonSetting, doClearDaemonSetting, doGetDaemonStatus, doSaveCustomWalletServers, doFetchDaemonSettings } from 'redux/actions/settings';
|
||||||
import { selectDaemonSettings, selectCachedWalletServers, makeSelectSharedPrefsForKey } from 'redux/selectors/settings';
|
import { selectDaemonSettings, selectSavedWalletServers, selectDaemonStatus, selectHasWalletServerPrefs } from 'redux/selectors/settings';
|
||||||
import SettingWalletServer from './view';
|
import SettingWalletServer from './view';
|
||||||
|
|
||||||
const select = state => ({
|
const select = state => ({
|
||||||
daemonSettings: selectDaemonSettings(state),
|
daemonSettings: selectDaemonSettings(state),
|
||||||
customServers: selectCachedWalletServers(state),
|
daemonStatus: selectDaemonStatus(state),
|
||||||
serverPrefs: makeSelectSharedPrefsForKey(DAEMON_SETTINGS.LBRYUM_SERVERS)(state),
|
customWalletServers: selectSavedWalletServers(state),
|
||||||
|
hasWalletServerPrefs: selectHasWalletServerPrefs(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
setWalletServers: (value) => dispatch(doSetDaemonSetting(DAEMON_SETTINGS.LBRYUM_SERVERS, value)),
|
setCustomWalletServers: (value) => dispatch(doSetDaemonSetting(DAEMON_SETTINGS.LBRYUM_SERVERS, value)),
|
||||||
clearWalletServers: () => dispatch(doClearDaemonSetting(DAEMON_SETTINGS.LBRYUM_SERVERS)),
|
clearWalletServers: () => dispatch(doClearDaemonSetting(DAEMON_SETTINGS.LBRYUM_SERVERS)),
|
||||||
getDaemonStatus: () => dispatch(doGetDaemonStatus()),
|
getDaemonStatus: () => dispatch(doGetDaemonStatus()),
|
||||||
saveServers: (servers) => dispatch(doCacheCustomWalletServers(servers)),
|
saveServerConfig: (servers) => dispatch(doSaveCustomWalletServers(servers)),
|
||||||
fetchDaemonSettings: () => dispatch(doFetchDaemonSettings()),
|
fetchDaemonSettings: () => dispatch(doFetchDaemonSettings()),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
// @flow
|
|
||||||
import * as ICONS from 'constants/icons';
|
|
||||||
import React from 'react';
|
|
||||||
import Button from 'component/button';
|
|
||||||
import Icon from 'component/common/icon';
|
|
||||||
|
|
||||||
type Props = {
|
|
||||||
host: string,
|
|
||||||
port: string,
|
|
||||||
available: boolean,
|
|
||||||
index: number,
|
|
||||||
remove: number => void,
|
|
||||||
};
|
|
||||||
|
|
||||||
function ServerDisplayRow(props: Props) {
|
|
||||||
const { host, port, available, index, remove } = props;
|
|
||||||
return (
|
|
||||||
<tr>
|
|
||||||
<td className="table__item--actionable">
|
|
||||||
{host}
|
|
||||||
</td>
|
|
||||||
<td className="table__item--actionable">
|
|
||||||
{port}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
{available && <Icon icon={ICONS.SUBSCRIBE} />}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<Button button={'link'} icon={ICONS.REMOVE} onClick={() => remove(index)} />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ServerDisplayRow;
|
|
|
@ -8,19 +8,20 @@ type Props = {
|
||||||
update: (string) => void,
|
update: (string) => void,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const VALID_IPADDRESS_REGEX = new RegExp('^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\.)){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$');
|
||||||
|
const VALID_HOSTNAME_REGEX = new RegExp('^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])(\\.))+([A-Za-z]|[A-Za-z][A-Za-z]*[A-Za-z])$');
|
||||||
|
const VALID_PORT_REGEX = new RegExp('^([0-9]){1,5}$');
|
||||||
|
|
||||||
function ServerInputRow(props: Props) {
|
function ServerInputRow(props: Props) {
|
||||||
const { update } = props;
|
const { update } = props;
|
||||||
const ValidIpAddressRegex = new RegExp('^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\.)){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$');
|
|
||||||
const ValidHostnameRegex = new RegExp('^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])(\\.))+([A-Za-z]|[A-Za-z][A-Za-z]*[A-Za-z])$');
|
|
||||||
const ValidPortRegex = new RegExp('^([0-9]){1,5}$');
|
|
||||||
|
|
||||||
const [hostString, setHostString] = useState('');
|
const [hostString, setHostString] = useState('');
|
||||||
const [portString, setPortString] = useState('');
|
const [portString, setPortString] = useState('');
|
||||||
const [valid, setValid] = useState(false);
|
const [validServerString, setValidServerString] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setValid((ValidIpAddressRegex.test(hostString) || ValidHostnameRegex.test(hostString)) && ValidPortRegex.test(portString));
|
setValidServerString((VALID_IPADDRESS_REGEX.test(hostString) || VALID_HOSTNAME_REGEX.test(hostString)) && VALID_PORT_REGEX.test(portString));
|
||||||
}, [hostString, portString, valid, setValid]);
|
}, [hostString, portString, validServerString, setValidServerString]);
|
||||||
|
|
||||||
function onClick() {
|
function onClick() {
|
||||||
update([hostString, portString]);
|
update([hostString, portString]);
|
||||||
|
@ -30,15 +31,15 @@ function ServerInputRow(props: Props) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<tr>
|
<tr>
|
||||||
<td> {/* host */}
|
<td>
|
||||||
<FormField type="text" value={hostString} onChange={e => setHostString(e.target.value)}/>
|
<FormField type="text" value={hostString} onChange={e => setHostString(e.target.value)} />
|
||||||
</td>
|
</td>
|
||||||
<td> {/* port */}
|
<td>
|
||||||
<FormField type="text" value={portString} onChange={e => setPortString(e.target.value)}/>
|
<FormField type="text" value={portString} onChange={e => setPortString(e.target.value)} />
|
||||||
</td>
|
</td>
|
||||||
<td />
|
<td />
|
||||||
<td>
|
<td>
|
||||||
<Button button={'link'} icon={ICONS.ADD} disabled={!valid} onClick={onClick}/>
|
<Button button={'link'} icon={ICONS.ADD} disabled={!validServerString} onClick={onClick} />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
|
|
|
@ -2,11 +2,18 @@
|
||||||
|
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { FormField } from 'component/common/form';
|
import { FormField } from 'component/common/form';
|
||||||
|
import Button from 'component/button';
|
||||||
|
import * as ICONS from 'constants/icons';
|
||||||
|
import Icon from 'component/common/icon';
|
||||||
|
|
||||||
import ServerInputRow from './internal/inputRow';
|
import ServerInputRow from './internal/inputRow';
|
||||||
import ServerDisplayRow from './internal/displayRow';
|
|
||||||
|
|
||||||
type DaemonSettings = {
|
type DaemonSettings = {
|
||||||
lbryum_servers: Array<>
|
lbryum_servers: Array<>,
|
||||||
|
};
|
||||||
|
|
||||||
|
type DaemonStatus = {
|
||||||
|
wallet: any,
|
||||||
};
|
};
|
||||||
|
|
||||||
type StatusOfServer = {
|
type StatusOfServer = {
|
||||||
|
@ -14,71 +21,69 @@ type StatusOfServer = {
|
||||||
port: string,
|
port: string,
|
||||||
availability: boolean,
|
availability: boolean,
|
||||||
latency: number,
|
latency: number,
|
||||||
}
|
};
|
||||||
|
|
||||||
type ServerInConfig = Array<string> // ['host', 'port']
|
type ServerTuple = Array<string>; // ['host', 'port']
|
||||||
|
|
||||||
type DisplayOfServer = {
|
type DisplayOfServer = {
|
||||||
host: string,
|
host: string,
|
||||||
port: string,
|
port: string,
|
||||||
availability: boolean,
|
availability: boolean,
|
||||||
}
|
};
|
||||||
|
|
||||||
type ServerStatus = Array<StatusOfServer>
|
type ServerStatus = Array<StatusOfServer>;
|
||||||
type ServerConfig = Array<ServerInConfig>
|
type ServerConfig = Array<ServerTuple>;
|
||||||
type DisplayList = Array<DisplayOfServer>
|
type DisplayList = Array<DisplayOfServer>;
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
daemonSettings: DaemonSettings,
|
daemonSettings: DaemonSettings,
|
||||||
getDaemonStatus: () => void,
|
getDaemonStatus: () => void,
|
||||||
setWalletServers: any => void,
|
setCustomWalletServers: any => void,
|
||||||
clearWalletServers: () => void,
|
clearWalletServers: () => void,
|
||||||
customServers: ServerConfig,
|
customWalletServers: ServerConfig,
|
||||||
saveServers: string => void,
|
saveServerConfig: string => void,
|
||||||
fetchDaemonSettings: () => void,
|
fetchDaemonSettings: () => void,
|
||||||
serverPrefs: ServerConfig,
|
hasWalletServerPrefs: boolean,
|
||||||
|
daemonStatus: DaemonStatus,
|
||||||
};
|
};
|
||||||
|
|
||||||
function SettingWalletServer(props: Props) {
|
function SettingWalletServer(props: Props) {
|
||||||
const {
|
const {
|
||||||
daemonSettings,
|
daemonSettings,
|
||||||
|
daemonStatus,
|
||||||
fetchDaemonSettings,
|
fetchDaemonSettings,
|
||||||
setWalletServers,
|
setCustomWalletServers,
|
||||||
getDaemonStatus,
|
getDaemonStatus,
|
||||||
clearWalletServers,
|
clearWalletServers,
|
||||||
saveServers,
|
saveServerConfig,
|
||||||
customServers,
|
customWalletServers,
|
||||||
serverPrefs,
|
hasWalletServerPrefs,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const [custom, setCustom] = useState(false);
|
const [advancedMode, setAdvancedMode] = useState(false);
|
||||||
const [status, setStatus] = useState([]);
|
|
||||||
const serversInConfig: ServerConfig = daemonSettings && daemonSettings.lbryum_servers;
|
const activeWalletServers: ServerStatus = (daemonStatus && daemonStatus.wallet && daemonStatus.wallet.servers) || [];
|
||||||
const servers = customServers.length ? customServers : serversInConfig;
|
const currentServerConfig: ServerConfig = daemonSettings && daemonSettings.lbryum_servers;
|
||||||
|
const serverConfig: ServerConfig = customWalletServers.length ? customWalletServers : currentServerConfig;
|
||||||
const STATUS_INTERVAL = 5000;
|
const STATUS_INTERVAL = 5000;
|
||||||
|
console.log(hasWalletServerPrefs)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (serverPrefs && serverPrefs.length) {
|
if (hasWalletServerPrefs) {
|
||||||
setCustom(true);
|
setAdvancedMode(true);
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// TODO: do this globally to have status updated for the app
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
getDaemonStatus()
|
getDaemonStatus();
|
||||||
.then(s => {
|
|
||||||
if (s && s.wallet && s.wallet.servers) {
|
|
||||||
setStatus(s.wallet.servers);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}, STATUS_INTERVAL);
|
}, STATUS_INTERVAL);
|
||||||
return () => clearInterval(interval);
|
return () => clearInterval(interval);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchDaemonSettings();
|
fetchDaemonSettings();
|
||||||
}, [custom]);
|
}, []);
|
||||||
|
|
||||||
function makeDisplayList(l) {
|
function makeDisplayList(l) {
|
||||||
const displayList = [];
|
const displayList = [];
|
||||||
|
@ -87,8 +92,7 @@ function SettingWalletServer(props: Props) {
|
||||||
host: entry[0],
|
host: entry[0],
|
||||||
port: entry[1],
|
port: entry[1],
|
||||||
available:
|
available:
|
||||||
(status && status.some(s => s.host === entry[0] && String(s.port) === entry[1] && s.availability)) ||
|
activeWalletServers.some(s => s.host === entry[0] && String(s.port) === entry[1] && s.availability) || false,
|
||||||
false,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return displayList;
|
return displayList;
|
||||||
|
@ -102,31 +106,36 @@ function SettingWalletServer(props: Props) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function doClear() {
|
function doClear() {
|
||||||
setCustom(false);
|
setAdvancedMode(false);
|
||||||
clearWalletServers();
|
clearWalletServers();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onAdd(serverTuple) {
|
function onAdd(serverTuple) {
|
||||||
let newServerConfig = servers.concat();
|
let newServerConfig = serverConfig.concat();
|
||||||
newServerConfig.push(serverTuple);
|
newServerConfig.push(serverTuple);
|
||||||
saveServers(newServerConfig);
|
updateServers(newServerConfig);
|
||||||
setWalletServers(makeServerParam(newServerConfig));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onDelete(i) {
|
function onDelete(i) {
|
||||||
const newServerList = servers.concat();
|
const newServerConfig = serverConfig.concat();
|
||||||
newServerList.splice(i, 1);
|
newServerConfig.splice(i, 1);
|
||||||
saveServers(newServerList);
|
updateServers(newServerConfig);
|
||||||
setWalletServers(makeServerParam(newServerList));
|
}
|
||||||
|
|
||||||
|
function updateServers(newConfig) {
|
||||||
|
saveServerConfig(newConfig);
|
||||||
|
setCustomWalletServers(makeServerParam(newConfig));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
|
<label>{__('Wallet servers')}</label>
|
||||||
|
<fieldset>
|
||||||
<FormField
|
<FormField
|
||||||
type="radio"
|
type="radio"
|
||||||
name="default_wallet_servers"
|
name="default_wallet_servers"
|
||||||
checked={!custom}
|
checked={!advancedMode}
|
||||||
label={__('lbry.tv wallet servers')}
|
label={__('lbry.tv')}
|
||||||
onChange={e => {
|
onChange={e => {
|
||||||
if (e.target.checked) {
|
if (e.target.checked) {
|
||||||
doClear();
|
doClear();
|
||||||
|
@ -136,16 +145,17 @@ function SettingWalletServer(props: Props) {
|
||||||
<FormField
|
<FormField
|
||||||
type="radio"
|
type="radio"
|
||||||
name="custom_wallet_servers"
|
name="custom_wallet_servers"
|
||||||
checked={custom}
|
checked={advancedMode}
|
||||||
onChange={e => {
|
onChange={e => {
|
||||||
setCustom(e.target.checked);
|
setAdvancedMode(e.target.checked);
|
||||||
if (e.target.checked) {
|
if (e.target.checked) {
|
||||||
setWalletServers(makeServerParam(customServers));
|
setCustomWalletServers(makeServerParam(customWalletServers));
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
label={__('Custom wallet servers')}
|
label={__('customize')}
|
||||||
/>
|
/>
|
||||||
{custom && (
|
</fieldset>
|
||||||
|
{advancedMode && (
|
||||||
<div>
|
<div>
|
||||||
<table className="table table--transactions">
|
<table className="table table--transactions">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -157,9 +167,16 @@ function SettingWalletServer(props: Props) {
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{servers &&
|
{serverConfig &&
|
||||||
makeDisplayList(servers).map((t, i) => (
|
makeDisplayList(serverConfig).map((t, i) => (
|
||||||
<ServerDisplayRow key={`${t.host}:${t.port}`} host={t.host} port={t.port} available={t.available} index={i} remove={onDelete} />
|
<tr key={`${t.host}:${t.port}`}>
|
||||||
|
<td>{t.host}</td>
|
||||||
|
<td>{t.port}</td>
|
||||||
|
<td>{t.available && <Icon icon={ICONS.SUBSCRIBE} />}</td>
|
||||||
|
<td>
|
||||||
|
<Button button={'link'} icon={ICONS.REMOVE} onClick={() => onDelete(i)} />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
))}
|
))}
|
||||||
<ServerInputRow update={onAdd} />
|
<ServerInputRow update={onAdd} />
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -160,7 +160,7 @@ export default class SplashScreen extends React.PureComponent<Props, State> {
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} else if (startupStatus && !startupStatus.wallet && wallet.available_servers < 1) {
|
} else if (startupStatus && !startupStatus.wallet && wallet && wallet.available_servers < 1) {
|
||||||
this.setState({waitingForWallet: this.state.waitingForWallet + (UPDATE_INTERVAL / 1000)});
|
this.setState({waitingForWallet: this.state.waitingForWallet + (UPDATE_INTERVAL / 1000)});
|
||||||
} else if (wallet && wallet.blocks_behind > 0) {
|
} else if (wallet && wallet.blocks_behind > 0) {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
|
|
@ -114,7 +114,6 @@ export const UPDATE_SEARCH_SUGGESTIONS = 'UPDATE_SEARCH_SUGGESTIONS';
|
||||||
export const DAEMON_SETTINGS_RECEIVED = 'DAEMON_SETTINGS_RECEIVED';
|
export const DAEMON_SETTINGS_RECEIVED = 'DAEMON_SETTINGS_RECEIVED';
|
||||||
export const CLIENT_SETTING_CHANGED = 'CLIENT_SETTING_CHANGED';
|
export const CLIENT_SETTING_CHANGED = 'CLIENT_SETTING_CHANGED';
|
||||||
export const UPDATE_IS_NIGHT = 'UPDATE_IS_NIGHT';
|
export const UPDATE_IS_NIGHT = 'UPDATE_IS_NIGHT';
|
||||||
export const WALLET_SERVERS_CACHED = 'WALLET_SERVERS_CACHED';
|
|
||||||
|
|
||||||
// User
|
// User
|
||||||
export const AUTHENTICATION_STARTED = 'AUTHENTICATION_STARTED';
|
export const AUTHENTICATION_STARTED = 'AUTHENTICATION_STARTED';
|
||||||
|
|
10
ui/index.jsx
10
ui/index.jsx
|
@ -290,11 +290,11 @@ function AppWrapper() {
|
||||||
</ConnectedRouter>
|
</ConnectedRouter>
|
||||||
) : (
|
) : (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<SplashScreen
|
<SplashScreen
|
||||||
authenticate={() => app.store.dispatch(doAuthenticate(pjson.version))}
|
authenticate={() => app.store.dispatch(doAuthenticate(pjson.version))}
|
||||||
onReadyToLaunch={() => setReadyToLaunch(true)}
|
onReadyToLaunch={() => setReadyToLaunch(true)}
|
||||||
/>
|
/>
|
||||||
<SnackBar />
|
<SnackBar />
|
||||||
</Fragment>
|
</Fragment>
|
||||||
)}
|
)}
|
||||||
</Fragment>
|
</Fragment>
|
||||||
|
|
|
@ -226,7 +226,6 @@ class SettingsPage extends React.PureComponent<Props, State> {
|
||||||
<div>
|
<div>
|
||||||
<Card title={__('Language')} actions={<SettingLanguage />} />
|
<Card title={__('Language')} actions={<SettingLanguage />} />
|
||||||
{/* @if TARGET='app' */}
|
{/* @if TARGET='app' */}
|
||||||
<Card title={__('Wallet Server')} actions={<SettingWalletServer />} />
|
|
||||||
<Card
|
<Card
|
||||||
title={__('Sync')}
|
title={__('Sync')}
|
||||||
subtitle={
|
subtitle={
|
||||||
|
@ -647,7 +646,8 @@ class SettingsPage extends React.PureComponent<Props, State> {
|
||||||
))}
|
))}
|
||||||
</FormField>
|
</FormField>
|
||||||
</fieldset-section>
|
</fieldset-section>
|
||||||
{/* @endif */}
|
<SettingWalletServer />
|
||||||
|
{/* @endif */}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Lbry, ACTIONS, doToast, SHARED_PREFS, doWalletReconnect } from 'lbry-redux';
|
import { Lbry, ACTIONS, doToast, SHARED_PREFERENCES, doWalletReconnect } from 'lbry-redux';
|
||||||
import * as SETTINGS from 'constants/settings';
|
import * as SETTINGS from 'constants/settings';
|
||||||
import * as LOCAL_ACTIONS from 'constants/action_types';
|
import * as LOCAL_ACTIONS from 'constants/action_types';
|
||||||
import analytics from 'analytics';
|
import analytics from 'analytics';
|
||||||
|
@ -23,19 +23,34 @@ export function doFetchDaemonSettings() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function doGetDaemonStatus() {
|
||||||
|
return dispatch => {
|
||||||
|
return Lbry.status().then(status => {
|
||||||
|
dispatch({
|
||||||
|
type: ACTIONS.DAEMON_STATUS_RECEIVED,
|
||||||
|
data: {
|
||||||
|
status,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return status;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
export function doClearDaemonSetting(key) {
|
export function doClearDaemonSetting(key) {
|
||||||
return dispatch => {
|
return dispatch => {
|
||||||
const clearKey = {
|
const clearKey = {
|
||||||
key,
|
key,
|
||||||
};
|
};
|
||||||
Lbry.settings_clear(clearKey).then(defaultSettings => {
|
Lbry.settings_clear(clearKey).then(defaultSettings => {
|
||||||
if (Object.values(SHARED_PREFS).includes(key)) {
|
if (Object.values(SHARED_PREFERENCES).includes(key)) {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.SHARED_PREFERENCE_SET,
|
type: ACTIONS.SHARED_PREFERENCE_SET,
|
||||||
data: { key: key, value: undefined },
|
data: { key: key, value: undefined },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (key === SHARED_PREFS.WALLET_SERVERS) {
|
if (key === SHARED_PREFERENCES.WALLET_SERVERS) {
|
||||||
dispatch(doWalletReconnect());
|
dispatch(doWalletReconnect());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -58,14 +73,14 @@ export function doSetDaemonSetting(key, value) {
|
||||||
value: !value && value !== false ? null : value,
|
value: !value && value !== false ? null : value,
|
||||||
};
|
};
|
||||||
Lbry.settings_set(newSettings).then(newSetting => {
|
Lbry.settings_set(newSettings).then(newSetting => {
|
||||||
if (Object.values(SHARED_PREFS).includes(key)) {
|
if (Object.values(SHARED_PREFERENCES).includes(key)) {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.SHARED_PREFERENCE_SET,
|
type: ACTIONS.SHARED_PREFERENCE_SET,
|
||||||
data: {key: key, value: newSetting[key]},
|
data: {key: key, value: newSetting[key]},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// hardcoding this in lieu of a better solution
|
// hardcoding this in lieu of a better solution
|
||||||
if (key === SHARED_PREFS.WALLET_SERVERS) {
|
if (key === SHARED_PREFERENCES.WALLET_SERVERS) {
|
||||||
dispatch(doWalletReconnect());
|
dispatch(doWalletReconnect());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -81,19 +96,13 @@ export function doSetDaemonSetting(key, value) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function doCacheCustomWalletServers(servers) {
|
export function doSaveCustomWalletServers(servers) {
|
||||||
return {
|
return {
|
||||||
type: ACTIONS.WALLET_SERVERS_CACHED,
|
type: ACTIONS.SAVE_CUSTOM_WALLET_SERVERS,
|
||||||
data: servers,
|
data: servers,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function doGetDaemonStatus() {
|
|
||||||
return dispatch => {
|
|
||||||
return Lbry.status().then(settings => settings);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export function doSetClientSetting(key, value) {
|
export function doSetClientSetting(key, value) {
|
||||||
return {
|
return {
|
||||||
type: ACTIONS.CLIENT_SETTING_CHANGED,
|
type: ACTIONS.CLIENT_SETTING_CHANGED,
|
||||||
|
|
|
@ -2,17 +2,18 @@ import * as ACTIONS from 'constants/action_types';
|
||||||
import * as SETTINGS from 'constants/settings';
|
import * as SETTINGS from 'constants/settings';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import SUPPORTED_LANGUAGES from 'constants/supported_languages';
|
import SUPPORTED_LANGUAGES from 'constants/supported_languages';
|
||||||
import { ACTIONS as LBRY_REDUX_ACTIONS, SHARED_PREFS } from 'lbry-redux';
|
import { ACTIONS as LBRY_REDUX_ACTIONS, SHARED_PREFERENCES } from 'lbry-redux';
|
||||||
|
|
||||||
const reducers = {};
|
const reducers = {};
|
||||||
const defaultState = {
|
const defaultState = {
|
||||||
isNight: false,
|
isNight: false,
|
||||||
loadedLanguages: [...Object.keys(window.i18n_messages), 'en'] || ['en'],
|
loadedLanguages: [...Object.keys(window.i18n_messages), 'en'] || ['en'],
|
||||||
customWalletServers: [],
|
customWalletServers: [],
|
||||||
sharedPrefs: {
|
sharedPreferences: {
|
||||||
[SHARED_PREFS.WALLET_SERVERS]: false,
|
[SHARED_PREFERENCES.WALLET_SERVERS]: false,
|
||||||
},
|
},
|
||||||
daemonSettings: {},
|
daemonSettings: {},
|
||||||
|
daemonStatus: {},
|
||||||
clientSettings: {
|
clientSettings: {
|
||||||
// UX
|
// UX
|
||||||
[SETTINGS.NEW_USER_ACKNOWLEDGED]: false,
|
[SETTINGS.NEW_USER_ACKNOWLEDGED]: false,
|
||||||
|
@ -56,11 +57,16 @@ const defaultState = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
reducers[ACTIONS.DAEMON_SETTINGS_RECEIVED] = (state, action) =>
|
reducers[LBRY_REDUX_ACTIONS.DAEMON_SETTINGS_RECEIVED] = (state, action) =>
|
||||||
Object.assign({}, state, {
|
Object.assign({}, state, {
|
||||||
daemonSettings: action.data.settings,
|
daemonSettings: action.data.settings,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
reducers[LBRY_REDUX_ACTIONS.DAEMON_STATUS_RECEIVED] = (state, action) =>
|
||||||
|
Object.assign({}, state, {
|
||||||
|
daemonStatus: action.data.status,
|
||||||
|
});
|
||||||
|
|
||||||
reducers[ACTIONS.CLIENT_SETTING_CHANGED] = (state, action) => {
|
reducers[ACTIONS.CLIENT_SETTING_CHANGED] = (state, action) => {
|
||||||
const { key, value } = action.data;
|
const { key, value } = action.data;
|
||||||
const clientSettings = Object.assign({}, state.clientSettings);
|
const clientSettings = Object.assign({}, state.clientSettings);
|
||||||
|
@ -99,11 +105,11 @@ reducers[ACTIONS.DOWNLOAD_LANGUAGE_SUCCESS] = (state, action) => {
|
||||||
|
|
||||||
reducers[LBRY_REDUX_ACTIONS.SHARED_PREFERENCE_SET] = (state, action) => {
|
reducers[LBRY_REDUX_ACTIONS.SHARED_PREFERENCE_SET] = (state, action) => {
|
||||||
const { key, value } = action.data;
|
const { key, value } = action.data;
|
||||||
const sharedPrefs = Object.assign({}, state.sharedPrefs);
|
const sharedPreferences = Object.assign({}, state.sharedPreferences);
|
||||||
sharedPrefs[key] = value;
|
sharedPreferences[key] = value;
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
sharedPrefs,
|
sharedPreferences,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,13 +128,13 @@ reducers[LBRY_REDUX_ACTIONS.USER_STATE_POPULATE] = (
|
||||||
state,
|
state,
|
||||||
action,
|
action,
|
||||||
) => {
|
) => {
|
||||||
const { settings: sharedPrefs } = action.data;
|
const { settings: sharedPreferences } = action.data;
|
||||||
|
|
||||||
// process clientSettings and daemonSettings
|
// process clientSettings and daemonSettings
|
||||||
return Object.assign({}, state, { sharedPrefs });
|
return Object.assign({}, state, { sharedPreferences });
|
||||||
};
|
};
|
||||||
|
|
||||||
reducers[ACTIONS.WALLET_SERVERS_CACHED] = (state, action) => {
|
reducers[LBRY_REDUX_ACTIONS.SAVE_CUSTOM_WALLET_SERVERS] = (state, action) => {
|
||||||
return Object.assign({}, state, {customWalletServers: action.data});
|
return Object.assign({}, state, {customWalletServers: action.data});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import * as SETTINGS from 'constants/settings';
|
import * as SETTINGS from 'constants/settings';
|
||||||
|
import { SHARED_PREFERENCES } from 'lbry-redux';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
|
||||||
const selectState = state => state.settings || {};
|
const selectState = state => state.settings || {};
|
||||||
|
@ -8,6 +9,11 @@ export const selectDaemonSettings = createSelector(
|
||||||
state => state.daemonSettings
|
state => state.daemonSettings
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const selectDaemonStatus = createSelector(
|
||||||
|
selectState,
|
||||||
|
state => state.daemonStatus
|
||||||
|
);
|
||||||
|
|
||||||
export const selectClientSettings = createSelector(
|
export const selectClientSettings = createSelector(
|
||||||
selectState,
|
selectState,
|
||||||
state => state.clientSettings || {}
|
state => state.clientSettings || {}
|
||||||
|
@ -34,22 +40,31 @@ export const selectIsNight = createSelector(
|
||||||
state => state.isNight
|
state => state.isNight
|
||||||
);
|
);
|
||||||
|
|
||||||
export const selectCachedWalletServers = createSelector(
|
export const selectSavedWalletServers = createSelector(
|
||||||
selectState,
|
selectState,
|
||||||
state => state.customWalletServers
|
state => state.customWalletServers
|
||||||
);
|
);
|
||||||
|
|
||||||
export const selectSharedPrefs = createSelector(
|
export const selectSharedPreferences = createSelector(
|
||||||
selectState,
|
selectState,
|
||||||
state => state.sharedPrefs
|
state => state.sharedPreferences
|
||||||
);
|
);
|
||||||
|
|
||||||
export const makeSelectSharedPrefsForKey = key =>
|
export const makeSelectSharedPreferencesForKey = key =>
|
||||||
createSelector(
|
createSelector(
|
||||||
selectSharedPrefs,
|
selectSharedPreferences,
|
||||||
prefs => (prefs ? prefs[key] : undefined)
|
prefs => (prefs ? prefs[key] : undefined)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const selectHasWalletServerPrefs =
|
||||||
|
createSelector(
|
||||||
|
makeSelectSharedPreferencesForKey(SHARED_PREFERENCES.WALLET_SERVERS),
|
||||||
|
servers => {
|
||||||
|
if (servers && servers.length) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
export const selectThemePath = createSelector(
|
export const selectThemePath = createSelector(
|
||||||
selectTheme,
|
selectTheme,
|
||||||
selectAutomaticDarkModeEnabled,
|
selectAutomaticDarkModeEnabled,
|
||||||
|
|
|
@ -130,7 +130,7 @@ const sharedStateFilters = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
blocked: { source: 'blocked', property: 'blockedChannels' },
|
blocked: { source: 'blocked', property: 'blockedChannels' },
|
||||||
settings: { source: 'settings', property: 'sharedPrefs'},
|
settings: { source: 'settings', property: 'sharedPreferences'},
|
||||||
};
|
};
|
||||||
|
|
||||||
const sharedStateCb = ({ dispatch, getState }) => {
|
const sharedStateCb = ({ dispatch, getState }) => {
|
||||||
|
|
|
@ -7066,9 +7066,9 @@ lazy-val@^1.0.4:
|
||||||
yargs "^13.2.2"
|
yargs "^13.2.2"
|
||||||
zstd-codec "^0.1.1"
|
zstd-codec "^0.1.1"
|
||||||
|
|
||||||
lbry-redux@lbryio/lbry-redux#9b11cfed62af7f0f8eb6fa3c88a1f8d2cce46afc:
|
lbry-redux@lbryio/lbry-redux#341d60661468b654b9baf5b96ca4a08ee202f0f2:
|
||||||
version "0.0.1"
|
version "0.0.1"
|
||||||
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/9b11cfed62af7f0f8eb6fa3c88a1f8d2cce46afc"
|
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/341d60661468b654b9baf5b96ca4a08ee202f0f2"
|
||||||
dependencies:
|
dependencies:
|
||||||
proxy-polyfill "0.1.6"
|
proxy-polyfill "0.1.6"
|
||||||
reselect "^3.0.0"
|
reselect "^3.0.0"
|
||||||
|
|
Loading…
Reference in a new issue