prettify all the files
This commit is contained in:
parent
202570f286
commit
aaec1f3a48
13 changed files with 368 additions and 353 deletions
36
ui/js/app.js
36
ui/js/app.js
|
@ -1,27 +1,27 @@
|
|||
import store from 'store.js';
|
||||
import lbry from './lbry.js';
|
||||
import store from "store.js";
|
||||
import lbry from "./lbry.js";
|
||||
|
||||
const env = ENV;
|
||||
const config = require(`./config/${env}`);
|
||||
const language = lbry.getClientSetting('language')
|
||||
? lbry.getClientSetting('language')
|
||||
: 'en';
|
||||
const i18n = require('y18n')({
|
||||
directory: 'app/locales',
|
||||
updateFiles: false,
|
||||
locale: language
|
||||
const language = lbry.getClientSetting("language")
|
||||
? lbry.getClientSetting("language")
|
||||
: "en";
|
||||
const i18n = require("y18n")({
|
||||
directory: "app/locales",
|
||||
updateFiles: false,
|
||||
locale: language,
|
||||
});
|
||||
const logs = [];
|
||||
const app = {
|
||||
env: env,
|
||||
config: config,
|
||||
store: store,
|
||||
i18n: i18n,
|
||||
logs: logs,
|
||||
log: function(message) {
|
||||
console.log(message);
|
||||
logs.push(message);
|
||||
}
|
||||
env: env,
|
||||
config: config,
|
||||
store: store,
|
||||
i18n: i18n,
|
||||
logs: logs,
|
||||
log: function(message) {
|
||||
console.log(message);
|
||||
logs.push(message);
|
||||
},
|
||||
};
|
||||
|
||||
window.__ = i18n.__;
|
||||
|
|
|
@ -4,11 +4,9 @@ import { doFetchCostInfoForUri } from "actions/cost_info";
|
|||
import {
|
||||
makeSelectCostInfoForUri,
|
||||
makeSelectFetchingCostInfoForUri,
|
||||
} from 'selectors/cost_info'
|
||||
import {
|
||||
makeSelectClaimForUri,
|
||||
} from 'selectors/claims'
|
||||
import FilePrice from './view'
|
||||
} from "selectors/cost_info";
|
||||
import { makeSelectClaimForUri } from "selectors/claims";
|
||||
import FilePrice from "./view";
|
||||
|
||||
const makeSelect = () => {
|
||||
const selectCostInfoForUri = makeSelectCostInfoForUri();
|
||||
|
|
|
@ -46,7 +46,9 @@ class UserEmailVerify extends React.PureComponent {
|
|||
{/* render help separately so it always shows */}
|
||||
<div className="form-field__helper">
|
||||
<p>
|
||||
{__("Email")} <Link href="mailto:help@lbry.io" label="help@lbry.io" /> {__("if you did not receive or are having trouble with your code.")}
|
||||
{__("Email")}{" "}
|
||||
<Link href="mailto:help@lbry.io" label="help@lbry.io" />{" "}
|
||||
{__("if you did not receive or are having trouble with your code.")}
|
||||
</p>
|
||||
</div>
|
||||
<div className="form-row-submit form-row-submit--with-footer">
|
||||
|
|
|
@ -13,12 +13,16 @@ class WelcomeModal extends React.PureComponent {
|
|||
<section>
|
||||
<h3 className="modal__header">{__("Welcome to LBRY.")}</h3>
|
||||
<p>
|
||||
{__("Using LBRY is like dating a centaur. Totally normal up top, and")}
|
||||
{__(
|
||||
"Using LBRY is like dating a centaur. Totally normal up top, and"
|
||||
)}
|
||||
{" "}<em>{__("way different")}</em> {__("underneath.")}
|
||||
</p>
|
||||
<p>{__("Up top, LBRY is similar to popular media sites.")}</p>
|
||||
<p>
|
||||
{__("Below, LBRY is controlled by users -- you -- via blockchain and decentralization.")}
|
||||
{__(
|
||||
"Below, LBRY is controlled by users -- you -- via blockchain and decentralization."
|
||||
)}
|
||||
</p>
|
||||
<p>
|
||||
{__("Thank you for making content freedom possible!")}
|
||||
|
@ -50,16 +54,24 @@ class WelcomeModal extends React.PureComponent {
|
|||
{" "}{__("LBRY credits, or")} <em>{__("LBC")}</em>.
|
||||
</p>
|
||||
<p>
|
||||
{__("This reward will show in your Wallet momentarily, probably while you are reading this message.")}
|
||||
{__(
|
||||
"This reward will show in your Wallet momentarily, probably while you are reading this message."
|
||||
)}
|
||||
</p>
|
||||
<p>
|
||||
{__("LBC is used to compensate creators, to publish, and to have say in how the network works.")}
|
||||
{__(
|
||||
"LBC is used to compensate creators, to publish, and to have say in how the network works."
|
||||
)}
|
||||
</p>
|
||||
<p>
|
||||
{__("No need to understand it all just yet! Try watching or downloading something next.")}
|
||||
{__(
|
||||
"No need to understand it all just yet! Try watching or downloading something next."
|
||||
)}
|
||||
</p>
|
||||
<p>
|
||||
{__("Finally, know that LBRY is an early beta and that it earns the name.")}
|
||||
{__(
|
||||
"Finally, know that LBRY is an early beta and that it earns the name."
|
||||
)}
|
||||
</p>
|
||||
</section>
|
||||
</Modal>;
|
||||
|
|
146
ui/js/jsonrpc.js
146
ui/js/jsonrpc.js
|
@ -1,87 +1,87 @@
|
|||
const jsonrpc = {};
|
||||
|
||||
jsonrpc.call = function(
|
||||
connectionString,
|
||||
method,
|
||||
params,
|
||||
callback,
|
||||
errorCallback,
|
||||
connectFailedCallback,
|
||||
timeout
|
||||
connectionString,
|
||||
method,
|
||||
params,
|
||||
callback,
|
||||
errorCallback,
|
||||
connectFailedCallback,
|
||||
timeout
|
||||
) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
if (typeof connectFailedCallback !== 'undefined') {
|
||||
if (timeout) {
|
||||
xhr.timeout = timeout;
|
||||
}
|
||||
var xhr = new XMLHttpRequest();
|
||||
if (typeof connectFailedCallback !== "undefined") {
|
||||
if (timeout) {
|
||||
xhr.timeout = timeout;
|
||||
}
|
||||
|
||||
xhr.addEventListener('error', function(e) {
|
||||
connectFailedCallback(e);
|
||||
});
|
||||
xhr.addEventListener('timeout', function() {
|
||||
connectFailedCallback(
|
||||
new Error(__('XMLHttpRequest connection timed out'))
|
||||
);
|
||||
});
|
||||
}
|
||||
xhr.addEventListener('load', function() {
|
||||
var response = JSON.parse(xhr.responseText);
|
||||
xhr.addEventListener("error", function(e) {
|
||||
connectFailedCallback(e);
|
||||
});
|
||||
xhr.addEventListener("timeout", function() {
|
||||
connectFailedCallback(
|
||||
new Error(__("XMLHttpRequest connection timed out"))
|
||||
);
|
||||
});
|
||||
}
|
||||
xhr.addEventListener("load", function() {
|
||||
var response = JSON.parse(xhr.responseText);
|
||||
|
||||
if (response.error) {
|
||||
if (errorCallback) {
|
||||
errorCallback(response.error);
|
||||
} else {
|
||||
var errorEvent = new CustomEvent('unhandledError', {
|
||||
detail: {
|
||||
connectionString: connectionString,
|
||||
method: method,
|
||||
params: params,
|
||||
code: response.error.code,
|
||||
message: response.error.message,
|
||||
data: response.error.data
|
||||
}
|
||||
});
|
||||
document.dispatchEvent(errorEvent);
|
||||
}
|
||||
} else if (callback) {
|
||||
callback(response.result);
|
||||
}
|
||||
});
|
||||
if (response.error) {
|
||||
if (errorCallback) {
|
||||
errorCallback(response.error);
|
||||
} else {
|
||||
var errorEvent = new CustomEvent("unhandledError", {
|
||||
detail: {
|
||||
connectionString: connectionString,
|
||||
method: method,
|
||||
params: params,
|
||||
code: response.error.code,
|
||||
message: response.error.message,
|
||||
data: response.error.data,
|
||||
},
|
||||
});
|
||||
document.dispatchEvent(errorEvent);
|
||||
}
|
||||
} else if (callback) {
|
||||
callback(response.result);
|
||||
}
|
||||
});
|
||||
|
||||
if (connectFailedCallback) {
|
||||
xhr.addEventListener('error', function(event) {
|
||||
connectFailedCallback(event);
|
||||
});
|
||||
} else {
|
||||
xhr.addEventListener('error', function(event) {
|
||||
var errorEvent = new CustomEvent('unhandledError', {
|
||||
detail: {
|
||||
connectionString: connectionString,
|
||||
method: method,
|
||||
params: params,
|
||||
code: xhr.status,
|
||||
message: __('Connection to API server failed')
|
||||
}
|
||||
});
|
||||
document.dispatchEvent(errorEvent);
|
||||
});
|
||||
}
|
||||
if (connectFailedCallback) {
|
||||
xhr.addEventListener("error", function(event) {
|
||||
connectFailedCallback(event);
|
||||
});
|
||||
} else {
|
||||
xhr.addEventListener("error", function(event) {
|
||||
var errorEvent = new CustomEvent("unhandledError", {
|
||||
detail: {
|
||||
connectionString: connectionString,
|
||||
method: method,
|
||||
params: params,
|
||||
code: xhr.status,
|
||||
message: __("Connection to API server failed"),
|
||||
},
|
||||
});
|
||||
document.dispatchEvent(errorEvent);
|
||||
});
|
||||
}
|
||||
|
||||
const counter = parseInt(sessionStorage.getItem('JSONRPCCounter') || 0);
|
||||
const counter = parseInt(sessionStorage.getItem("JSONRPCCounter") || 0);
|
||||
|
||||
xhr.open('POST', connectionString, true);
|
||||
xhr.send(
|
||||
JSON.stringify({
|
||||
jsonrpc: '2.0',
|
||||
method: method,
|
||||
params: params,
|
||||
id: counter
|
||||
})
|
||||
);
|
||||
xhr.open("POST", connectionString, true);
|
||||
xhr.send(
|
||||
JSON.stringify({
|
||||
jsonrpc: "2.0",
|
||||
method: method,
|
||||
params: params,
|
||||
id: counter,
|
||||
})
|
||||
);
|
||||
|
||||
sessionStorage.setItem('JSONRPCCounter', counter + 1);
|
||||
sessionStorage.setItem("JSONRPCCounter", counter + 1);
|
||||
|
||||
return xhr;
|
||||
return xhr;
|
||||
};
|
||||
|
||||
export default jsonrpc;
|
||||
|
|
|
@ -417,7 +417,7 @@ lbry.file_list = function(params = {}) {
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
apiCall(
|
||||
"file_list",
|
||||
params,
|
||||
|
@ -458,7 +458,6 @@ lbry.claim_list_mine = function(params = {}) {
|
|||
});
|
||||
};
|
||||
|
||||
|
||||
lbry._resolveXhrs = {};
|
||||
lbry.resolve = function(params = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
|
350
ui/js/lbryuri.js
350
ui/js/lbryuri.js
|
@ -26,125 +26,125 @@ const lbryuri = {};
|
|||
* - channelName (string, if present): Channel name without @
|
||||
*/
|
||||
lbryuri.parse = function(uri, requireProto = false) {
|
||||
// Break into components. Empty sub-matches are converted to null
|
||||
const componentsRegex = new RegExp(
|
||||
'^((?:lbry://)?)' + // protocol
|
||||
'([^:$#/]*)' + // name (stops at the first separator or end)
|
||||
'([:$#]?)([^/]*)' + // modifier separator, modifier (stops at the first path separator or end)
|
||||
'(/?)(.*)' // path separator, path
|
||||
);
|
||||
const [proto, name, modSep, modVal, pathSep, path] = componentsRegex
|
||||
.exec(uri)
|
||||
.slice(1)
|
||||
.map(match => match || null);
|
||||
// Break into components. Empty sub-matches are converted to null
|
||||
const componentsRegex = new RegExp(
|
||||
"^((?:lbry://)?)" + // protocol
|
||||
"([^:$#/]*)" + // name (stops at the first separator or end)
|
||||
"([:$#]?)([^/]*)" + // modifier separator, modifier (stops at the first path separator or end)
|
||||
"(/?)(.*)" // path separator, path
|
||||
);
|
||||
const [proto, name, modSep, modVal, pathSep, path] = componentsRegex
|
||||
.exec(uri)
|
||||
.slice(1)
|
||||
.map(match => match || null);
|
||||
|
||||
let contentName;
|
||||
let contentName;
|
||||
|
||||
// Validate protocol
|
||||
if (requireProto && !proto) {
|
||||
throw new Error(__('LBRY URIs must include a protocol prefix (lbry://).'));
|
||||
}
|
||||
// Validate protocol
|
||||
if (requireProto && !proto) {
|
||||
throw new Error(__("LBRY URIs must include a protocol prefix (lbry://)."));
|
||||
}
|
||||
|
||||
// Validate and process name
|
||||
if (!name) {
|
||||
throw new Error(__('URI does not include name.'));
|
||||
}
|
||||
// Validate and process name
|
||||
if (!name) {
|
||||
throw new Error(__("URI does not include name."));
|
||||
}
|
||||
|
||||
const isChannel = name.startsWith('@');
|
||||
const channelName = isChannel ? name.slice(1) : name;
|
||||
const isChannel = name.startsWith("@");
|
||||
const channelName = isChannel ? name.slice(1) : name;
|
||||
|
||||
if (isChannel) {
|
||||
if (!channelName) {
|
||||
throw new Error(__('No channel name after @.'));
|
||||
}
|
||||
if (isChannel) {
|
||||
if (!channelName) {
|
||||
throw new Error(__("No channel name after @."));
|
||||
}
|
||||
|
||||
if (channelName.length < CHANNEL_NAME_MIN_LEN) {
|
||||
throw new Error(
|
||||
__(
|
||||
`Channel names must be at least %s characters.`,
|
||||
CHANNEL_NAME_MIN_LEN
|
||||
)
|
||||
);
|
||||
}
|
||||
if (channelName.length < CHANNEL_NAME_MIN_LEN) {
|
||||
throw new Error(
|
||||
__(
|
||||
`Channel names must be at least %s characters.`,
|
||||
CHANNEL_NAME_MIN_LEN
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
contentName = path;
|
||||
}
|
||||
contentName = path;
|
||||
}
|
||||
|
||||
const nameBadChars = (channelName || name).match(/[^A-Za-z0-9-]/g);
|
||||
if (nameBadChars) {
|
||||
throw new Error(
|
||||
__(
|
||||
`Invalid character %s in name: %s.`,
|
||||
nameBadChars.length == 1 ? '' : 's',
|
||||
nameBadChars.join(', ')
|
||||
)
|
||||
);
|
||||
}
|
||||
const nameBadChars = (channelName || name).match(/[^A-Za-z0-9-]/g);
|
||||
if (nameBadChars) {
|
||||
throw new Error(
|
||||
__(
|
||||
`Invalid character %s in name: %s.`,
|
||||
nameBadChars.length == 1 ? "" : "s",
|
||||
nameBadChars.join(", ")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Validate and process modifier (claim ID, bid position or claim sequence)
|
||||
let claimId, claimSequence, bidPosition;
|
||||
if (modSep) {
|
||||
if (!modVal) {
|
||||
throw new Error(__(`No modifier provided after separator %s.`, modSep));
|
||||
}
|
||||
// Validate and process modifier (claim ID, bid position or claim sequence)
|
||||
let claimId, claimSequence, bidPosition;
|
||||
if (modSep) {
|
||||
if (!modVal) {
|
||||
throw new Error(__(`No modifier provided after separator %s.`, modSep));
|
||||
}
|
||||
|
||||
if (modSep == '#') {
|
||||
claimId = modVal;
|
||||
} else if (modSep == ':') {
|
||||
claimSequence = modVal;
|
||||
} else if (modSep == '$') {
|
||||
bidPosition = modVal;
|
||||
}
|
||||
}
|
||||
if (modSep == "#") {
|
||||
claimId = modVal;
|
||||
} else if (modSep == ":") {
|
||||
claimSequence = modVal;
|
||||
} else if (modSep == "$") {
|
||||
bidPosition = modVal;
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
claimId &&
|
||||
(claimId.length > CLAIM_ID_MAX_LEN || !claimId.match(/^[0-9a-f]+$/))
|
||||
) {
|
||||
throw new Error(__(`Invalid claim ID %s.`, claimId));
|
||||
}
|
||||
if (
|
||||
claimId &&
|
||||
(claimId.length > CLAIM_ID_MAX_LEN || !claimId.match(/^[0-9a-f]+$/))
|
||||
) {
|
||||
throw new Error(__(`Invalid claim ID %s.`, claimId));
|
||||
}
|
||||
|
||||
if (claimSequence && !claimSequence.match(/^-?[1-9][0-9]*$/)) {
|
||||
throw new Error(__('Claim sequence must be a number.'));
|
||||
}
|
||||
if (claimSequence && !claimSequence.match(/^-?[1-9][0-9]*$/)) {
|
||||
throw new Error(__("Claim sequence must be a number."));
|
||||
}
|
||||
|
||||
if (bidPosition && !bidPosition.match(/^-?[1-9][0-9]*$/)) {
|
||||
throw new Error(__('Bid position must be a number.'));
|
||||
}
|
||||
if (bidPosition && !bidPosition.match(/^-?[1-9][0-9]*$/)) {
|
||||
throw new Error(__("Bid position must be a number."));
|
||||
}
|
||||
|
||||
// Validate and process path
|
||||
if (path) {
|
||||
if (!isChannel) {
|
||||
throw new Error(__('Only channel URIs may have a path.'));
|
||||
}
|
||||
// Validate and process path
|
||||
if (path) {
|
||||
if (!isChannel) {
|
||||
throw new Error(__("Only channel URIs may have a path."));
|
||||
}
|
||||
|
||||
const pathBadChars = path.match(/[^A-Za-z0-9-]/g);
|
||||
if (pathBadChars) {
|
||||
throw new Error(
|
||||
__(
|
||||
`Invalid character %s in path: %s`,
|
||||
count == 1 ? '' : 's',
|
||||
nameBadChars.join(', ')
|
||||
)
|
||||
);
|
||||
}
|
||||
const pathBadChars = path.match(/[^A-Za-z0-9-]/g);
|
||||
if (pathBadChars) {
|
||||
throw new Error(
|
||||
__(
|
||||
`Invalid character %s in path: %s`,
|
||||
count == 1 ? "" : "s",
|
||||
nameBadChars.join(", ")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
contentName = path;
|
||||
} else if (pathSep) {
|
||||
throw new Error(__('No path provided after /'));
|
||||
}
|
||||
contentName = path;
|
||||
} else if (pathSep) {
|
||||
throw new Error(__("No path provided after /"));
|
||||
}
|
||||
|
||||
return {
|
||||
name,
|
||||
path,
|
||||
isChannel,
|
||||
...(contentName ? { contentName } : {}),
|
||||
...(channelName ? { channelName } : {}),
|
||||
...(claimSequence ? { claimSequence: parseInt(claimSequence) } : {}),
|
||||
...(bidPosition ? { bidPosition: parseInt(bidPosition) } : {}),
|
||||
...(claimId ? { claimId } : {}),
|
||||
...(path ? { path } : {})
|
||||
};
|
||||
return {
|
||||
name,
|
||||
path,
|
||||
isChannel,
|
||||
...(contentName ? { contentName } : {}),
|
||||
...(channelName ? { channelName } : {}),
|
||||
...(claimSequence ? { claimSequence: parseInt(claimSequence) } : {}),
|
||||
...(bidPosition ? { bidPosition: parseInt(bidPosition) } : {}),
|
||||
...(claimId ? { claimId } : {}),
|
||||
...(path ? { path } : {}),
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -153,96 +153,96 @@ lbryuri.parse = function(uri, requireProto = false) {
|
|||
* The channelName key will accept names with or without the @ prefix.
|
||||
*/
|
||||
lbryuri.build = function(uriObj, includeProto = true, allowExtraProps = false) {
|
||||
let {
|
||||
name,
|
||||
claimId,
|
||||
claimSequence,
|
||||
bidPosition,
|
||||
path,
|
||||
contentName,
|
||||
channelName
|
||||
} = uriObj;
|
||||
let {
|
||||
name,
|
||||
claimId,
|
||||
claimSequence,
|
||||
bidPosition,
|
||||
path,
|
||||
contentName,
|
||||
channelName,
|
||||
} = uriObj;
|
||||
|
||||
if (channelName) {
|
||||
const channelNameFormatted = channelName.startsWith('@')
|
||||
? channelName
|
||||
: '@' + channelName;
|
||||
if (!name) {
|
||||
name = channelNameFormatted;
|
||||
} else if (name !== channelNameFormatted) {
|
||||
throw new Error(
|
||||
__(
|
||||
'Received a channel content URI, but name and channelName do not match. "name" represents the value in the name position of the URI (lbry://name...), which for channel content will be the channel name. In most cases, to construct a channel URI you should just pass channelName and contentName.'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
if (channelName) {
|
||||
const channelNameFormatted = channelName.startsWith("@")
|
||||
? channelName
|
||||
: "@" + channelName;
|
||||
if (!name) {
|
||||
name = channelNameFormatted;
|
||||
} else if (name !== channelNameFormatted) {
|
||||
throw new Error(
|
||||
__(
|
||||
'Received a channel content URI, but name and channelName do not match. "name" represents the value in the name position of the URI (lbry://name...), which for channel content will be the channel name. In most cases, to construct a channel URI you should just pass channelName and contentName.'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (contentName) {
|
||||
if (!name) {
|
||||
name = contentName;
|
||||
} else if (!path) {
|
||||
path = contentName;
|
||||
}
|
||||
if (path && path !== contentName) {
|
||||
throw new Error(
|
||||
__(
|
||||
'Path and contentName do not match. Only one is required; most likely you wanted contentName.'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
if (contentName) {
|
||||
if (!name) {
|
||||
name = contentName;
|
||||
} else if (!path) {
|
||||
path = contentName;
|
||||
}
|
||||
if (path && path !== contentName) {
|
||||
throw new Error(
|
||||
__(
|
||||
"Path and contentName do not match. Only one is required; most likely you wanted contentName."
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
(includeProto ? 'lbry://' : '') +
|
||||
name +
|
||||
(claimId ? `#${claimId}` : '') +
|
||||
(claimSequence ? `:${claimSequence}` : '') +
|
||||
(bidPosition ? `\$${bidPosition}` : '') +
|
||||
(path ? `/${path}` : '')
|
||||
);
|
||||
return (
|
||||
(includeProto ? "lbry://" : "") +
|
||||
name +
|
||||
(claimId ? `#${claimId}` : "") +
|
||||
(claimSequence ? `:${claimSequence}` : "") +
|
||||
(bidPosition ? `\$${bidPosition}` : "") +
|
||||
(path ? `/${path}` : "")
|
||||
);
|
||||
};
|
||||
|
||||
/* Takes a parseable LBRY URI and converts it to standard, canonical format (currently this just
|
||||
* consists of adding the lbry:// prefix if needed) */
|
||||
lbryuri.normalize = function(uri) {
|
||||
const { name, path, bidPosition, claimSequence, claimId } = lbryuri.parse(
|
||||
uri
|
||||
);
|
||||
return lbryuri.build({ name, path, claimSequence, bidPosition, claimId });
|
||||
const { name, path, bidPosition, claimSequence, claimId } = lbryuri.parse(
|
||||
uri
|
||||
);
|
||||
return lbryuri.build({ name, path, claimSequence, bidPosition, claimId });
|
||||
};
|
||||
|
||||
lbryuri.isValid = function(uri) {
|
||||
let parts;
|
||||
try {
|
||||
parts = lbryuri.parse(lbryuri.normalize(uri));
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
return parts && parts.name;
|
||||
let parts;
|
||||
try {
|
||||
parts = lbryuri.parse(lbryuri.normalize(uri));
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
return parts && parts.name;
|
||||
};
|
||||
|
||||
lbryuri.isValidName = function(name, checkCase = true) {
|
||||
const regexp = new RegExp('^[a-z0-9-]+$', checkCase ? '' : 'i');
|
||||
return regexp.test(name);
|
||||
const regexp = new RegExp("^[a-z0-9-]+$", checkCase ? "" : "i");
|
||||
return regexp.test(name);
|
||||
};
|
||||
|
||||
lbryuri.isClaimable = function(uri) {
|
||||
let parts;
|
||||
try {
|
||||
parts = lbryuri.parse(lbryuri.normalize(uri));
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
parts &&
|
||||
parts.name &&
|
||||
!parts.claimId &&
|
||||
!parts.bidPosition &&
|
||||
!parts.claimSequence &&
|
||||
!parts.isChannel &&
|
||||
!parts.path
|
||||
);
|
||||
let parts;
|
||||
try {
|
||||
parts = lbryuri.parse(lbryuri.normalize(uri));
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
parts &&
|
||||
parts.name &&
|
||||
!parts.claimId &&
|
||||
!parts.bidPosition &&
|
||||
!parts.claimSequence &&
|
||||
!parts.isChannel &&
|
||||
!parts.path
|
||||
);
|
||||
};
|
||||
|
||||
window.lbryuri = lbryuri;
|
||||
|
|
|
@ -1,84 +1,84 @@
|
|||
import lbry from './lbry.js';
|
||||
import jsonrpc from './jsonrpc.js';
|
||||
import lbry from "./lbry.js";
|
||||
import jsonrpc from "./jsonrpc.js";
|
||||
|
||||
const queryTimeout = 3000;
|
||||
const maxQueryTries = 2;
|
||||
const defaultServers = [
|
||||
'http://lighthouse7.lbry.io:50005',
|
||||
'http://lighthouse8.lbry.io:50005',
|
||||
'http://lighthouse9.lbry.io:50005'
|
||||
"http://lighthouse7.lbry.io:50005",
|
||||
"http://lighthouse8.lbry.io:50005",
|
||||
"http://lighthouse9.lbry.io:50005",
|
||||
];
|
||||
const path = '/';
|
||||
const path = "/";
|
||||
|
||||
let server = null;
|
||||
let connectTryNum = 0;
|
||||
|
||||
function getServers() {
|
||||
return lbry.getClientSetting('useCustomLighthouseServers')
|
||||
? lbry.getClientSetting('customLighthouseServers')
|
||||
: defaultServers;
|
||||
return lbry.getClientSetting("useCustomLighthouseServers")
|
||||
? lbry.getClientSetting("customLighthouseServers")
|
||||
: defaultServers;
|
||||
}
|
||||
|
||||
function call(method, params, callback, errorCallback) {
|
||||
if (connectTryNum >= maxQueryTries) {
|
||||
errorCallback(
|
||||
new Error(
|
||||
__(
|
||||
`Could not connect to Lighthouse server. Last server attempted: %s`,
|
||||
server
|
||||
)
|
||||
)
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (connectTryNum >= maxQueryTries) {
|
||||
errorCallback(
|
||||
new Error(
|
||||
__(
|
||||
`Could not connect to Lighthouse server. Last server attempted: %s`,
|
||||
server
|
||||
)
|
||||
)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Set the Lighthouse server if it hasn't been set yet, if the current server is not in current
|
||||
* set of servers (most likely because of a settings change), or we're re-trying after a failed
|
||||
* query.
|
||||
*/
|
||||
if (!server || !getServers().includes(server) || connectTryNum > 0) {
|
||||
// If there's a current server, filter it out so we get a new one
|
||||
const newServerChoices = server
|
||||
? getServers().filter(s => s != server)
|
||||
: getServers();
|
||||
server =
|
||||
newServerChoices[
|
||||
Math.round(Math.random() * (newServerChoices.length - 1))
|
||||
];
|
||||
}
|
||||
if (!server || !getServers().includes(server) || connectTryNum > 0) {
|
||||
// If there's a current server, filter it out so we get a new one
|
||||
const newServerChoices = server
|
||||
? getServers().filter(s => s != server)
|
||||
: getServers();
|
||||
server =
|
||||
newServerChoices[
|
||||
Math.round(Math.random() * (newServerChoices.length - 1))
|
||||
];
|
||||
}
|
||||
|
||||
jsonrpc.call(
|
||||
server + path,
|
||||
method,
|
||||
params,
|
||||
response => {
|
||||
connectTryNum = 0;
|
||||
callback(response);
|
||||
},
|
||||
error => {
|
||||
connectTryNum = 0;
|
||||
errorCallback(error);
|
||||
},
|
||||
() => {
|
||||
connectTryNum++;
|
||||
call(method, params, callback, errorCallback);
|
||||
},
|
||||
queryTimeout
|
||||
);
|
||||
jsonrpc.call(
|
||||
server + path,
|
||||
method,
|
||||
params,
|
||||
response => {
|
||||
connectTryNum = 0;
|
||||
callback(response);
|
||||
},
|
||||
error => {
|
||||
connectTryNum = 0;
|
||||
errorCallback(error);
|
||||
},
|
||||
() => {
|
||||
connectTryNum++;
|
||||
call(method, params, callback, errorCallback);
|
||||
},
|
||||
queryTimeout
|
||||
);
|
||||
}
|
||||
|
||||
const lighthouse = new Proxy(
|
||||
{},
|
||||
{
|
||||
get: function(target, name) {
|
||||
return function(...params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
call(name, params, resolve, reject);
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
{},
|
||||
{
|
||||
get: function(target, name) {
|
||||
return function(...params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
call(name, params, resolve, reject);
|
||||
});
|
||||
};
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
export default lighthouse;
|
||||
|
|
|
@ -5,9 +5,6 @@ import FileCard from "component/fileCard";
|
|||
import { BusyMessage } from "component/common.js";
|
||||
import ToolTip from "component/tooltip.js";
|
||||
|
||||
|
||||
|
||||
|
||||
const FeaturedCategory = props => {
|
||||
const { category, names } = props;
|
||||
|
||||
|
@ -19,7 +16,9 @@ const FeaturedCategory = props => {
|
|||
category.match(/^community/i) &&
|
||||
<ToolTip
|
||||
label={__("What's this?")}
|
||||
body={__("Community Content is a public space where anyone can share content with the rest of the LBRY community. Bid on the names \"one,\" \"two,\" \"three,\" \"four\" and \"five\" to put your content here!")}
|
||||
body={__(
|
||||
'Community Content is a public space where anyone can share content with the rest of the LBRY community. Bid on the names "one," "two," "three," "four" and "five" to put your content here!'
|
||||
)}
|
||||
className="tooltip--header"
|
||||
/>}
|
||||
</h3>
|
||||
|
|
|
@ -15,7 +15,8 @@ const perform = dispatch => ({
|
|||
back: () => dispatch(doHistoryBack()),
|
||||
navigate: path => dispatch(doNavigate(path)),
|
||||
fetchClaimListMine: () => dispatch(doFetchClaimListMine()),
|
||||
claimFirstChannelReward: () => dispatch(doClaimRewardType(rewards.TYPE_FIRST_CHANNEL)),
|
||||
claimFirstChannelReward: () =>
|
||||
dispatch(doClaimRewardType(rewards.TYPE_FIRST_CHANNEL)),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(PublishPage);
|
||||
|
|
|
@ -437,7 +437,8 @@ class PublishPage extends React.PureComponent {
|
|||
return (
|
||||
<span>
|
||||
{__(
|
||||
'A deposit of at least one credit is required to win "%s". However, you can still get a permanent URL for any amount.', this.state.name
|
||||
'A deposit of at least one credit is required to win "%s". However, you can still get a permanent URL for any amount.',
|
||||
this.state.name
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
|
@ -445,7 +446,9 @@ class PublishPage extends React.PureComponent {
|
|||
return (
|
||||
<span>
|
||||
{__(
|
||||
'A deposit of at least "%s" credits is required to win "%s". However, you can still get a permanent URL for any amount.', this.state.topClaimValue, this.state.name
|
||||
'A deposit of at least "%s" credits is required to win "%s". However, you can still get a permanent URL for any amount.',
|
||||
this.state.topClaimValue,
|
||||
this.state.name
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
|
|
|
@ -60,7 +60,8 @@ const RewardsPage = props => {
|
|||
<p>{__("You are not eligible to claim rewards.")}</p>
|
||||
<p>
|
||||
{__("To become eligible, email")}
|
||||
{" "}<Link href="mailto:help@lbry.io" label="help@lbry.io" /> {__("with a link to a public social media profile.")}
|
||||
{" "}<Link href="mailto:help@lbry.io" label="help@lbry.io" />{" "}
|
||||
{__("with a link to a public social media profile.")}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -3,15 +3,15 @@
|
|||
* is not set yet.
|
||||
*/
|
||||
export function getLocal(key, fallback = undefined) {
|
||||
const itemRaw = localStorage.getItem(key);
|
||||
return itemRaw === null ? fallback : JSON.parse(itemRaw);
|
||||
const itemRaw = localStorage.getItem(key);
|
||||
return itemRaw === null ? fallback : JSON.parse(itemRaw);
|
||||
}
|
||||
|
||||
/**
|
||||
* Thin wrapper around localStorage.setItem(). Converts value to JSON.
|
||||
*/
|
||||
export function setLocal(key, value) {
|
||||
localStorage.setItem(key, JSON.stringify(value));
|
||||
localStorage.setItem(key, JSON.stringify(value));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,13 +19,13 @@ export function setLocal(key, value) {
|
|||
* is not set yet.
|
||||
*/
|
||||
export function getSession(key, fallback = undefined) {
|
||||
const itemRaw = sessionStorage.getItem(key);
|
||||
return itemRaw === null ? fallback : JSON.parse(itemRaw);
|
||||
const itemRaw = sessionStorage.getItem(key);
|
||||
return itemRaw === null ? fallback : JSON.parse(itemRaw);
|
||||
}
|
||||
|
||||
/**
|
||||
* Thin wrapper around localStorage.setItem(). Converts value to JSON.
|
||||
*/
|
||||
export function setSession(key, value) {
|
||||
sessionStorage.setItem(key, JSON.stringify(value));
|
||||
sessionStorage.setItem(key, JSON.stringify(value));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue