From e07ab27b1310cbd0bc96a3a63cc47da65d91938e Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Mon, 18 Feb 2019 21:50:40 +0100 Subject: [PATCH] fixes for mobile errors (#115) --- dist/bundle.js | 31 +++++++++++++++++++------------ src/lbry.js | 1 + src/redux/selectors/navigation.js | 2 +- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/dist/bundle.js b/dist/bundle.js index 59b2c24..c195502 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -1974,9 +1974,11 @@ module.exports = v4; // and inconsistent support for the `crypto` API. We do the best we can via // feature-detection -// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. -var getRandomValues = (typeof(crypto) != 'undefined' && crypto.getRandomValues.bind(crypto)) || - (typeof(msCrypto) != 'undefined' && msCrypto.getRandomValues.bind(msCrypto)); +// getRandomValues needs to be invoked in a context where "this" is a Crypto +// implementation. Also, find the complete implementation of crypto on IE11. +var getRandomValues = (typeof(crypto) != 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto)) || + (typeof(msCrypto) != 'undefined' && typeof window.msCrypto.getRandomValues == 'function' && msCrypto.getRandomValues.bind(msCrypto)); + if (getRandomValues) { // WHATWG crypto RNG - http://wiki.whatwg.org/wiki/Crypto var rnds8 = new Uint8Array(16); // eslint-disable-line no-undef @@ -2019,14 +2021,15 @@ for (var i = 0; i < 256; ++i) { function bytesToUuid(buf, offset) { var i = offset || 0; var bth = byteToHex; - return bth[buf[i++]] + bth[buf[i++]] + - bth[buf[i++]] + bth[buf[i++]] + '-' + - bth[buf[i++]] + bth[buf[i++]] + '-' + - bth[buf[i++]] + bth[buf[i++]] + '-' + - bth[buf[i++]] + bth[buf[i++]] + '-' + - bth[buf[i++]] + bth[buf[i++]] + - bth[buf[i++]] + bth[buf[i++]] + - bth[buf[i++]] + bth[buf[i++]]; + // join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4 + return ([bth[buf[i++]], bth[buf[i++]], + bth[buf[i++]], bth[buf[i++]], '-', + bth[buf[i++]], bth[buf[i++]], '-', + bth[buf[i++]], bth[buf[i++]], '-', + bth[buf[i++]], bth[buf[i++]], '-', + bth[buf[i++]], bth[buf[i++]], + bth[buf[i++]], bth[buf[i++]], + bth[buf[i++]], bth[buf[i++]]]).join(''); } module.exports = bytesToUuid; @@ -2484,6 +2487,10 @@ Lbry.transaction_list = function () { var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; return daemonCallWithResult('transaction_list', params); }; +Lbry.utxo_release = function () { + var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + return daemonCallWithResult('utxo_release', params); +}; Lbry.connectPromise = null; Lbry.connect = function () { @@ -3679,7 +3686,7 @@ var selectCurrentPath = exports.selectCurrentPath = (0, _reselect.createSelector }); var computePageFromPath = exports.computePageFromPath = function computePageFromPath(path) { - return path.replace(/^\//, '').split('?')[0]; + return path ? path.replace(/^\//, '').split('?')[0] : 1; }; var selectCurrentPage = exports.selectCurrentPage = (0, _reselect.createSelector)(selectCurrentPath, function (path) { diff --git a/src/lbry.js b/src/lbry.js index 194fe77..feda33c 100644 --- a/src/lbry.js +++ b/src/lbry.js @@ -89,6 +89,7 @@ Lbry.claim_tip = (params = {}) => daemonCallWithResult('claim_tip', params); // transactions Lbry.transaction_list = (params = {}) => daemonCallWithResult('transaction_list', params); +Lbry.utxo_release = (params = {}) => daemonCallWithResult('utxo_release', params); Lbry.connectPromise = null; Lbry.connect = () => { diff --git a/src/redux/selectors/navigation.js b/src/redux/selectors/navigation.js index e494cf5..8aafd3c 100644 --- a/src/redux/selectors/navigation.js +++ b/src/redux/selectors/navigation.js @@ -5,7 +5,7 @@ export const selectState = state => state.navigation || {}; export const selectCurrentPath = createSelector(selectState, state => state.currentPath); -export const computePageFromPath = path => path.replace(/^\//, '').split('?')[0]; +export const computePageFromPath = path => (path ? path.replace(/^\//, '').split('?')[0] : ''); export const selectCurrentPage = createSelector(selectCurrentPath, path => computePageFromPath(path)