Merge pull request #119 from lbryio/lbryinc
[BREAKING CHANGE] remove refs to api.lbry.io
This commit is contained in:
commit
f140db38dd
13 changed files with 105 additions and 1579 deletions
1243
dist/bundle.js
vendored
1243
dist/bundle.js
vendored
File diff suppressed because it is too large
Load diff
|
@ -61,10 +61,6 @@ export const SET_TRANSACTION_LIST_FILTER = 'SET_TRANSACTION_LIST_FILTER';
|
||||||
export const UPDATE_CURRENT_HEIGHT = 'UPDATE_CURRENT_HEIGHT';
|
export const UPDATE_CURRENT_HEIGHT = 'UPDATE_CURRENT_HEIGHT';
|
||||||
|
|
||||||
// Claims
|
// Claims
|
||||||
export const FETCH_FEATURED_CONTENT_STARTED = 'FETCH_FEATURED_CONTENT_STARTED';
|
|
||||||
export const FETCH_FEATURED_CONTENT_COMPLETED = 'FETCH_FEATURED_CONTENT_COMPLETED';
|
|
||||||
export const FETCH_TRENDING_CONTENT_STARTED = 'FETCH_TRENDING_CONTENT_STARTED';
|
|
||||||
export const FETCH_TRENDING_CONTENT_COMPLETED = 'FETCH_TRENDING_CONTENT_COMPLETED';
|
|
||||||
export const RESOLVE_URIS_STARTED = 'RESOLVE_URIS_STARTED';
|
export const RESOLVE_URIS_STARTED = 'RESOLVE_URIS_STARTED';
|
||||||
export const RESOLVE_URIS_COMPLETED = 'RESOLVE_URIS_COMPLETED';
|
export const RESOLVE_URIS_COMPLETED = 'RESOLVE_URIS_COMPLETED';
|
||||||
export const FETCH_CHANNEL_CLAIMS_STARTED = 'FETCH_CHANNEL_CLAIMS_STARTED';
|
export const FETCH_CHANNEL_CLAIMS_STARTED = 'FETCH_CHANNEL_CLAIMS_STARTED';
|
||||||
|
@ -82,10 +78,6 @@ export const CREATE_CHANNEL_COMPLETED = 'CREATE_CHANNEL_COMPLETED';
|
||||||
export const PUBLISH_STARTED = 'PUBLISH_STARTED';
|
export const PUBLISH_STARTED = 'PUBLISH_STARTED';
|
||||||
export const PUBLISH_COMPLETED = 'PUBLISH_COMPLETED';
|
export const PUBLISH_COMPLETED = 'PUBLISH_COMPLETED';
|
||||||
export const PUBLISH_FAILED = 'PUBLISH_FAILED';
|
export const PUBLISH_FAILED = 'PUBLISH_FAILED';
|
||||||
export const FETCH_BLACK_LISTED_CONTENT_STARTED = 'FETCH_BLACK_LISTED_CONTENT_STARTED';
|
|
||||||
export const FETCH_BLACK_LISTED_CONTENT_COMPLETED = 'FETCH_BLACK_LISTED_CONTENT_COMPLETED';
|
|
||||||
export const FETCH_BLACK_LISTED_CONTENT_FAILED = 'FETCH_BLACK_LISTED_CONTENT_FAILED';
|
|
||||||
export const BLACK_LISTED_CONTENT_SUBSCRIBE = 'BLACK_LISTED_CONTENT_SUBSCRIBE';
|
|
||||||
export const SET_PLAYING_URI = 'SET_PLAYING_URI';
|
export const SET_PLAYING_URI = 'SET_PLAYING_URI';
|
||||||
export const SET_CONTENT_POSITION = 'SET_CONTENT_POSITION';
|
export const SET_CONTENT_POSITION = 'SET_CONTENT_POSITION';
|
||||||
export const SET_CONTENT_LAST_VIEWED = 'SET_CONTENT_LAST_VIEWED';
|
export const SET_CONTENT_LAST_VIEWED = 'SET_CONTENT_LAST_VIEWED';
|
||||||
|
@ -97,8 +89,6 @@ export const FILE_LIST_STARTED = 'FILE_LIST_STARTED';
|
||||||
export const FILE_LIST_SUCCEEDED = 'FILE_LIST_SUCCEEDED';
|
export const FILE_LIST_SUCCEEDED = 'FILE_LIST_SUCCEEDED';
|
||||||
export const FETCH_FILE_INFO_STARTED = 'FETCH_FILE_INFO_STARTED';
|
export const FETCH_FILE_INFO_STARTED = 'FETCH_FILE_INFO_STARTED';
|
||||||
export const FETCH_FILE_INFO_COMPLETED = 'FETCH_FILE_INFO_COMPLETED';
|
export const FETCH_FILE_INFO_COMPLETED = 'FETCH_FILE_INFO_COMPLETED';
|
||||||
export const FETCH_COST_INFO_STARTED = 'FETCH_COST_INFO_STARTED';
|
|
||||||
export const FETCH_COST_INFO_COMPLETED = 'FETCH_COST_INFO_COMPLETED';
|
|
||||||
export const LOADING_VIDEO_STARTED = 'LOADING_VIDEO_STARTED';
|
export const LOADING_VIDEO_STARTED = 'LOADING_VIDEO_STARTED';
|
||||||
export const LOADING_VIDEO_COMPLETED = 'LOADING_VIDEO_COMPLETED';
|
export const LOADING_VIDEO_COMPLETED = 'LOADING_VIDEO_COMPLETED';
|
||||||
export const LOADING_VIDEO_FAILED = 'LOADING_VIDEO_FAILED';
|
export const LOADING_VIDEO_FAILED = 'LOADING_VIDEO_FAILED';
|
||||||
|
|
21
src/index.js
21
src/index.js
|
@ -7,7 +7,6 @@ import * as PAGES from 'constants/pages';
|
||||||
import { SEARCH_TYPES, SEARCH_OPTIONS } from 'constants/search';
|
import { SEARCH_TYPES, SEARCH_OPTIONS } from 'constants/search';
|
||||||
|
|
||||||
import Lbry from 'lbry';
|
import Lbry from 'lbry';
|
||||||
import Lbryapi from 'lbryapi';
|
|
||||||
import { selectState as selectSearchState } from 'redux/selectors/search';
|
import { selectState as selectSearchState } from 'redux/selectors/search';
|
||||||
|
|
||||||
// types
|
// types
|
||||||
|
@ -26,7 +25,7 @@ export {
|
||||||
};
|
};
|
||||||
|
|
||||||
// common
|
// common
|
||||||
export { Lbry, Lbryapi };
|
export { Lbry };
|
||||||
export {
|
export {
|
||||||
regexInvalidURI,
|
regexInvalidURI,
|
||||||
regexAddress,
|
regexAddress,
|
||||||
|
@ -49,12 +48,8 @@ export {
|
||||||
doAbandonClaim,
|
doAbandonClaim,
|
||||||
doResolveUris,
|
doResolveUris,
|
||||||
doResolveUri,
|
doResolveUri,
|
||||||
doFetchFeaturedUris,
|
|
||||||
doFetchTrendingUris,
|
|
||||||
} from 'redux/actions/claims';
|
} from 'redux/actions/claims';
|
||||||
|
|
||||||
export { doFetchCostInfoForUri } from 'redux/actions/cost_info';
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
doFetchFileInfo,
|
doFetchFileInfo,
|
||||||
doFileList,
|
doFileList,
|
||||||
|
@ -71,8 +66,6 @@ export {
|
||||||
doUpdateSearchOptions,
|
doUpdateSearchOptions,
|
||||||
} from 'redux/actions/search';
|
} from 'redux/actions/search';
|
||||||
|
|
||||||
export { doBlackListedOutpointsSubscribe } from 'redux/actions/blacklist';
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
doUpdateBalance,
|
doUpdateBalance,
|
||||||
doBalanceSubscribe,
|
doBalanceSubscribe,
|
||||||
|
@ -99,16 +92,12 @@ export { formatCredits, formatFullPrice, creditsToString } from 'util/formatCred
|
||||||
|
|
||||||
// reducers
|
// reducers
|
||||||
export { claimsReducer } from 'redux/reducers/claims';
|
export { claimsReducer } from 'redux/reducers/claims';
|
||||||
export { costInfoReducer } from 'redux/reducers/cost_info';
|
|
||||||
export { fileInfoReducer } from 'redux/reducers/file_info';
|
export { fileInfoReducer } from 'redux/reducers/file_info';
|
||||||
export { notificationsReducer } from 'redux/reducers/notifications';
|
export { notificationsReducer } from 'redux/reducers/notifications';
|
||||||
export { searchReducer } from 'redux/reducers/search';
|
export { searchReducer } from 'redux/reducers/search';
|
||||||
export { walletReducer } from 'redux/reducers/wallet';
|
export { walletReducer } from 'redux/reducers/wallet';
|
||||||
export { blacklistReducer } from 'redux/reducers/blacklist';
|
|
||||||
|
|
||||||
// selectors
|
// selectors
|
||||||
export { selectBlackListedOutpoints } from 'redux/selectors/blacklist';
|
|
||||||
|
|
||||||
export { selectToast, selectError } from 'redux/selectors/notifications';
|
export { selectToast, selectError } from 'redux/selectors/notifications';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
@ -157,14 +146,6 @@ export {
|
||||||
selectCurrentChannelPage,
|
selectCurrentChannelPage,
|
||||||
} from 'redux/selectors/claims';
|
} from 'redux/selectors/claims';
|
||||||
|
|
||||||
export {
|
|
||||||
makeSelectFetchingCostInfoForUri,
|
|
||||||
makeSelectCostInfoForUri,
|
|
||||||
selectAllCostInfoByUri,
|
|
||||||
selectCostForCurrentPageUri,
|
|
||||||
selectFetchingCostInfo,
|
|
||||||
} from 'redux/selectors/cost_info';
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
makeSelectFileInfoForUri,
|
makeSelectFileInfoForUri,
|
||||||
makeSelectDownloadingForUri,
|
makeSelectDownloadingForUri,
|
||||||
|
|
|
@ -1,84 +0,0 @@
|
||||||
import querystring from 'querystring';
|
|
||||||
|
|
||||||
const Lbryapi = {
|
|
||||||
enabled: true,
|
|
||||||
exchangePromise: null,
|
|
||||||
exchangeLastFetched: null,
|
|
||||||
};
|
|
||||||
|
|
||||||
const CONNECTION_STRING = process.env.LBRY_APP_API_URL
|
|
||||||
? process.env.LBRY_APP_API_URL.replace(/\/*$/, '/') // exactly one slash at the end
|
|
||||||
: 'https://api.lbry.io/';
|
|
||||||
|
|
||||||
const EXCHANGE_RATE_TIMEOUT = 20 * 60 * 1000;
|
|
||||||
|
|
||||||
Lbryapi.getExchangeRates = () => {
|
|
||||||
if (
|
|
||||||
!Lbryapi.exchangeLastFetched ||
|
|
||||||
Date.now() - Lbryapi.exchangeLastFetched > EXCHANGE_RATE_TIMEOUT
|
|
||||||
) {
|
|
||||||
Lbryapi.exchangePromise = new Promise((resolve, reject) => {
|
|
||||||
Lbryapi.call('lbc', 'exchange_rate', {}, 'get', true)
|
|
||||||
.then(({ lbc_usd: LBC_USD, lbc_btc: LBC_BTC, btc_usd: BTC_USD }) => {
|
|
||||||
const rates = { LBC_USD, LBC_BTC, BTC_USD };
|
|
||||||
resolve(rates);
|
|
||||||
})
|
|
||||||
.catch(reject);
|
|
||||||
});
|
|
||||||
Lbryapi.exchangeLastFetched = Date.now();
|
|
||||||
}
|
|
||||||
return Lbryapi.exchangePromise;
|
|
||||||
};
|
|
||||||
|
|
||||||
Lbryapi.call = (resource, action, params = {}, method = 'get') => {
|
|
||||||
if (!Lbryapi.enabled) {
|
|
||||||
return Promise.reject(new Error(__('LBRY internal API is disabled')));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(method === 'get' || method === 'post')) {
|
|
||||||
return Promise.reject(new Error(__('Invalid method')));
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkAndParse(response) {
|
|
||||||
if (response.status >= 200 && response.status < 300) {
|
|
||||||
return response.json();
|
|
||||||
}
|
|
||||||
return response.json().then(json => {
|
|
||||||
let error;
|
|
||||||
if (json.error) {
|
|
||||||
error = new Error(json.error);
|
|
||||||
} else {
|
|
||||||
error = new Error('Unknown API error signature');
|
|
||||||
}
|
|
||||||
error.response = response; // This is primarily a hack used in actions/user.js
|
|
||||||
return Promise.reject(error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function makeRequest(url, options) {
|
|
||||||
return fetch(url, options).then(checkAndParse);
|
|
||||||
}
|
|
||||||
|
|
||||||
const fullParams = { ...params };
|
|
||||||
const qs = querystring.stringify(fullParams);
|
|
||||||
let url = `${CONNECTION_STRING}${resource}/${action}?${qs}`;
|
|
||||||
|
|
||||||
let options = {
|
|
||||||
method: 'GET',
|
|
||||||
};
|
|
||||||
|
|
||||||
if (method === 'post') {
|
|
||||||
options = {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
|
||||||
},
|
|
||||||
body: qs,
|
|
||||||
};
|
|
||||||
url = `${CONNECTION_STRING}${resource}/${action}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return makeRequest(url, options).then(response => response.data);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Lbryapi;
|
|
|
@ -1,48 +0,0 @@
|
||||||
import Lbryapi from 'lbryapi';
|
|
||||||
import * as ACTIONS from 'constants/action_types';
|
|
||||||
|
|
||||||
const CHECK_BLACK_LISTED_CONTENT_INTERVAL = 60 * 60 * 1000;
|
|
||||||
|
|
||||||
export function doFetchBlackListedOutpoints() {
|
|
||||||
return dispatch => {
|
|
||||||
dispatch({
|
|
||||||
type: ACTIONS.FETCH_BLACK_LISTED_CONTENT_STARTED,
|
|
||||||
});
|
|
||||||
|
|
||||||
const success = ({ outpoints }) => {
|
|
||||||
const splitedOutpoints = [];
|
|
||||||
|
|
||||||
outpoints.forEach((outpoint, index) => {
|
|
||||||
const [txid, nout] = outpoint.split(':');
|
|
||||||
|
|
||||||
splitedOutpoints[index] = { txid, nout: Number.parseInt(nout, 10) };
|
|
||||||
});
|
|
||||||
dispatch({
|
|
||||||
type: ACTIONS.FETCH_BLACK_LISTED_CONTENT_COMPLETED,
|
|
||||||
data: {
|
|
||||||
outpoints: splitedOutpoints,
|
|
||||||
success: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const failure = ({ error }) => {
|
|
||||||
dispatch({
|
|
||||||
type: ACTIONS.FETCH_BLACK_LISTED_CONTENT_FAILED,
|
|
||||||
data: {
|
|
||||||
error,
|
|
||||||
success: false,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
Lbryapi.call('file', 'list_blocked').then(success, failure);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function doBlackListedOutpointsSubscribe() {
|
|
||||||
return dispatch => {
|
|
||||||
dispatch(doFetchBlackListedOutpoints());
|
|
||||||
setInterval(() => dispatch(doFetchBlackListedOutpoints()), CHECK_BLACK_LISTED_CONTENT_INTERVAL);
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,10 +1,8 @@
|
||||||
import * as ACTIONS from 'constants/action_types';
|
import * as ACTIONS from 'constants/action_types';
|
||||||
import Lbry from 'lbry';
|
import Lbry from 'lbry';
|
||||||
import Lbryapi from 'lbryapi';
|
|
||||||
import { normalizeURI } from 'lbryURI';
|
import { normalizeURI } from 'lbryURI';
|
||||||
import { doToast } from 'redux/actions/notifications';
|
import { doToast } from 'redux/actions/notifications';
|
||||||
import { selectMyClaimsRaw, selectResolvingUris, selectClaimsByUri } from 'redux/selectors/claims';
|
import { selectMyClaimsRaw, selectResolvingUris, selectClaimsByUri } from 'redux/selectors/claims';
|
||||||
import { batchActions } from 'util/batchActions';
|
|
||||||
import { doFetchTransactions } from 'redux/actions/wallet';
|
import { doFetchTransactions } from 'redux/actions/wallet';
|
||||||
|
|
||||||
export function doResolveUris(uris, returnCachedClaims = false) {
|
export function doResolveUris(uris, returnCachedClaims = false) {
|
||||||
|
@ -134,81 +132,6 @@ export function doAbandonClaim(txid, nout) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function doFetchFeaturedUris(offloadResolve = false) {
|
|
||||||
return dispatch => {
|
|
||||||
dispatch({
|
|
||||||
type: ACTIONS.FETCH_FEATURED_CONTENT_STARTED,
|
|
||||||
});
|
|
||||||
|
|
||||||
const success = ({ Uris }) => {
|
|
||||||
let urisToResolve = [];
|
|
||||||
Object.keys(Uris).forEach(category => {
|
|
||||||
urisToResolve = [...urisToResolve, ...Uris[category]];
|
|
||||||
});
|
|
||||||
|
|
||||||
const actions = [
|
|
||||||
{
|
|
||||||
type: ACTIONS.FETCH_FEATURED_CONTENT_COMPLETED,
|
|
||||||
data: {
|
|
||||||
uris: Uris,
|
|
||||||
success: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
if (urisToResolve.length && !offloadResolve) {
|
|
||||||
actions.push(doResolveUris(urisToResolve));
|
|
||||||
}
|
|
||||||
|
|
||||||
dispatch(batchActions(...actions));
|
|
||||||
};
|
|
||||||
|
|
||||||
const failure = () => {
|
|
||||||
dispatch({
|
|
||||||
type: ACTIONS.FETCH_FEATURED_CONTENT_COMPLETED,
|
|
||||||
data: {
|
|
||||||
uris: {},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
Lbryapi.call('file', 'list_homepage').then(success, failure);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function doFetchTrendingUris() {
|
|
||||||
return dispatch => {
|
|
||||||
dispatch({
|
|
||||||
type: ACTIONS.FETCH_TRENDING_CONTENT_STARTED,
|
|
||||||
});
|
|
||||||
|
|
||||||
const success = data => {
|
|
||||||
const urisToResolve = data.map(uri => uri.url);
|
|
||||||
const actions = [
|
|
||||||
doResolveUris(urisToResolve),
|
|
||||||
{
|
|
||||||
type: ACTIONS.FETCH_TRENDING_CONTENT_COMPLETED,
|
|
||||||
data: {
|
|
||||||
uris: data,
|
|
||||||
success: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
dispatch(batchActions(...actions));
|
|
||||||
};
|
|
||||||
|
|
||||||
const failure = () => {
|
|
||||||
dispatch({
|
|
||||||
type: ACTIONS.FETCH_TRENDING_CONTENT_COMPLETED,
|
|
||||||
data: {
|
|
||||||
uris: [],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
Lbryapi.call('file', 'list_trending').then(success, failure);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function doFetchClaimsByChannel(uri, page) {
|
export function doFetchClaimsByChannel(uri, page) {
|
||||||
return dispatch => {
|
return dispatch => {
|
||||||
dispatch({
|
dispatch({
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
import * as ACTIONS from 'constants/action_types';
|
|
||||||
import LbryApi from 'lbryapi';
|
|
||||||
import { selectClaimsByUri } from 'redux/selectors/claims';
|
|
||||||
|
|
||||||
// eslint-disable-next-line import/prefer-default-export
|
|
||||||
export function doFetchCostInfoForUri(uri) {
|
|
||||||
return (dispatch, getState) => {
|
|
||||||
const state = getState();
|
|
||||||
const claim = selectClaimsByUri(state)[uri];
|
|
||||||
|
|
||||||
if (!claim) return;
|
|
||||||
|
|
||||||
function resolve(costInfo) {
|
|
||||||
dispatch({
|
|
||||||
type: ACTIONS.FETCH_COST_INFO_COMPLETED,
|
|
||||||
data: {
|
|
||||||
uri,
|
|
||||||
costInfo,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const fee =
|
|
||||||
claim.value && claim.value.stream && claim.value.stream.metadata
|
|
||||||
? claim.value.stream.metadata.fee
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
if (fee === undefined) {
|
|
||||||
resolve({ cost: 0, includesData: true });
|
|
||||||
} else if (fee.currency === 'LBC') {
|
|
||||||
resolve({ cost: fee.amount, includesData: true });
|
|
||||||
} else {
|
|
||||||
LbryApi.getExchangeRates().then(({ LBC_USD }) => {
|
|
||||||
resolve({ cost: fee.amount / LBC_USD, includesData: true });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
import * as ACTIONS from 'constants/action_types';
|
|
||||||
import { handleActions } from 'util/redux-utils';
|
|
||||||
|
|
||||||
const defaultState = {
|
|
||||||
fetchingBlackListedOutpoints: false,
|
|
||||||
fetchingBlackListedOutpointsSucceed: undefined,
|
|
||||||
blackListedOutpoints: undefined,
|
|
||||||
};
|
|
||||||
|
|
||||||
export const blacklistReducer = handleActions(
|
|
||||||
{
|
|
||||||
[ACTIONS.FETCH_BLACK_LISTED_CONTENT_STARTED]: state => ({
|
|
||||||
...state,
|
|
||||||
fetchingBlackListedOutpoints: true,
|
|
||||||
}),
|
|
||||||
[ACTIONS.FETCH_BLACK_LISTED_CONTENT_COMPLETED]: (state, action) => {
|
|
||||||
const { outpoints, success } = action.data;
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
fetchingBlackListedOutpoints: false,
|
|
||||||
fetchingBlackListedOutpointsSucceed: success,
|
|
||||||
blackListedOutpoints: outpoints,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
[ACTIONS.FETCH_BLACK_LISTED_CONTENT_FAILED]: (state, action) => {
|
|
||||||
const { error, success } = action.data;
|
|
||||||
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
fetchingBlackListedOutpoints: false,
|
|
||||||
fetchingBlackListedOutpointsSucceed: success,
|
|
||||||
fetchingBlackListedOutpointsError: error,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
},
|
|
||||||
defaultState
|
|
||||||
);
|
|
|
@ -41,11 +41,11 @@ reducers[ACTIONS.RESOLVE_URIS_COMPLETED] = (state, action) => {
|
||||||
byId,
|
byId,
|
||||||
claimsByUri: byUri,
|
claimsByUri: byUri,
|
||||||
channelClaimCounts,
|
channelClaimCounts,
|
||||||
resolvingUris: (state.resolvingUris || []).filter((uri) => !resolveInfo[uri]),
|
resolvingUris: (state.resolvingUris || []).filter(uri => !resolveInfo[uri]),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
reducers[ACTIONS.FETCH_CLAIM_LIST_MINE_STARTED] = (state) =>
|
reducers[ACTIONS.FETCH_CLAIM_LIST_MINE_STARTED] = state =>
|
||||||
Object.assign({}, state, {
|
Object.assign({}, state, {
|
||||||
isFetchingClaimListMine: true,
|
isFetchingClaimListMine: true,
|
||||||
});
|
});
|
||||||
|
@ -56,7 +56,7 @@ reducers[ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED] = (state, action) => {
|
||||||
const byUri = Object.assign({}, state.claimsByUri);
|
const byUri = Object.assign({}, state.claimsByUri);
|
||||||
const pendingById = Object.assign({}, state.pendingById);
|
const pendingById = Object.assign({}, state.pendingById);
|
||||||
|
|
||||||
claims.forEach((claim) => {
|
claims.forEach(claim => {
|
||||||
const uri = buildURI({ claimName: claim.name, claimId: claim.claim_id });
|
const uri = buildURI({ claimName: claim.name, claimId: claim.claim_id });
|
||||||
|
|
||||||
if (claim.type && claim.type.match(/claim|update/)) {
|
if (claim.type && claim.type.match(/claim|update/)) {
|
||||||
|
@ -73,8 +73,8 @@ reducers[ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED] = (state, action) => {
|
||||||
|
|
||||||
// Remove old pending publishes
|
// Remove old pending publishes
|
||||||
Object.values(pendingById)
|
Object.values(pendingById)
|
||||||
.filter((pendingClaim) => byId[pendingClaim.claim_id])
|
.filter(pendingClaim => byId[pendingClaim.claim_id])
|
||||||
.forEach((pendingClaim) => {
|
.forEach(pendingClaim => {
|
||||||
delete pendingById[pendingClaim.claim_id];
|
delete pendingById[pendingClaim.claim_id];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ reducers[ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED] = (state, action) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
reducers[ACTIONS.FETCH_CHANNEL_LIST_STARTED] = (state) =>
|
reducers[ACTIONS.FETCH_CHANNEL_LIST_STARTED] = state =>
|
||||||
Object.assign({}, state, { fetchingMyChannels: true });
|
Object.assign({}, state, { fetchingMyChannels: true });
|
||||||
|
|
||||||
reducers[ACTIONS.FETCH_CHANNEL_LIST_COMPLETED] = (state, action) => {
|
reducers[ACTIONS.FETCH_CHANNEL_LIST_COMPLETED] = (state, action) => {
|
||||||
|
@ -95,7 +95,7 @@ reducers[ACTIONS.FETCH_CHANNEL_LIST_COMPLETED] = (state, action) => {
|
||||||
const myChannelClaims = new Set(state.myChannelClaims);
|
const myChannelClaims = new Set(state.myChannelClaims);
|
||||||
const byId = Object.assign({}, state.byId);
|
const byId = Object.assign({}, state.byId);
|
||||||
|
|
||||||
claims.forEach((claim) => {
|
claims.forEach(claim => {
|
||||||
myChannelClaims.add(claim.claim_id);
|
myChannelClaims.add(claim.claim_id);
|
||||||
byId[claim.claim_id] = claim;
|
byId[claim.claim_id] = claim;
|
||||||
});
|
});
|
||||||
|
@ -131,7 +131,7 @@ reducers[ACTIONS.FETCH_CHANNEL_CLAIMS_COMPLETED] = (state, action) => {
|
||||||
const claimsByUri = Object.assign({}, state.claimsByUri);
|
const claimsByUri = Object.assign({}, state.claimsByUri);
|
||||||
|
|
||||||
if (claims !== undefined) {
|
if (claims !== undefined) {
|
||||||
claims.forEach((claim) => {
|
claims.forEach(claim => {
|
||||||
allClaimIds.add(claim.claim_id);
|
allClaimIds.add(claim.claim_id);
|
||||||
currentPageClaimIds.push(claim.claim_id);
|
currentPageClaimIds.push(claim.claim_id);
|
||||||
byId[claim.claim_id] = claim;
|
byId[claim.claim_id] = claim;
|
||||||
|
@ -169,7 +169,7 @@ reducers[ACTIONS.ABANDON_CLAIM_SUCCEEDED] = (state, action) => {
|
||||||
const byId = Object.assign({}, state.byId);
|
const byId = Object.assign({}, state.byId);
|
||||||
const claimsByUri = Object.assign({}, state.claimsByUri);
|
const claimsByUri = Object.assign({}, state.claimsByUri);
|
||||||
|
|
||||||
Object.keys(claimsByUri).forEach((uri) => {
|
Object.keys(claimsByUri).forEach(uri => {
|
||||||
if (claimsByUri[uri] === claimId) {
|
if (claimsByUri[uri] === claimId) {
|
||||||
delete claimsByUri[uri];
|
delete claimsByUri[uri];
|
||||||
}
|
}
|
||||||
|
@ -197,43 +197,13 @@ reducers[ACTIONS.CREATE_CHANNEL_COMPLETED] = (state, action) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
reducers[ACTIONS.FETCH_FEATURED_CONTENT_STARTED] = (state) =>
|
|
||||||
Object.assign({}, state, {
|
|
||||||
fetchingFeaturedContent: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
reducers[ACTIONS.FETCH_FEATURED_CONTENT_COMPLETED] = (state, action) => {
|
|
||||||
const { uris, success } = action.data;
|
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
|
||||||
fetchingFeaturedContent: false,
|
|
||||||
fetchingFeaturedContentFailed: !success,
|
|
||||||
featuredUris: uris,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
reducers[ACTIONS.FETCH_TRENDING_CONTENT_STARTED] = (state) =>
|
|
||||||
Object.assign({}, state, {
|
|
||||||
fetchingTrendingContent: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
reducers[ACTIONS.FETCH_TRENDING_CONTENT_COMPLETED] = (state, action) => {
|
|
||||||
const { uris, success } = action.data;
|
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
|
||||||
fetchingTrendingContent: false,
|
|
||||||
fetchingTrendingContentFailed: !success,
|
|
||||||
trendingUris: uris,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
reducers[ACTIONS.RESOLVE_URIS_STARTED] = (state, action) => {
|
reducers[ACTIONS.RESOLVE_URIS_STARTED] = (state, action) => {
|
||||||
const { uris } = action.data;
|
const { uris } = action.data;
|
||||||
|
|
||||||
const oldResolving = state.resolvingUris || [];
|
const oldResolving = state.resolvingUris || [];
|
||||||
const newResolving = Object.assign([], oldResolving);
|
const newResolving = Object.assign([], oldResolving);
|
||||||
|
|
||||||
uris.forEach((uri) => {
|
uris.forEach(uri => {
|
||||||
if (!newResolving.includes(uri)) {
|
if (!newResolving.includes(uri)) {
|
||||||
newResolving.push(uri);
|
newResolving.push(uri);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
import * as ACTIONS from 'constants/action_types';
|
|
||||||
|
|
||||||
const reducers = {};
|
|
||||||
const defaultState = {};
|
|
||||||
|
|
||||||
reducers[ACTIONS.FETCH_COST_INFO_STARTED] = (state, action) => {
|
|
||||||
const { uri } = action.data;
|
|
||||||
const newFetching = Object.assign({}, state.fetching);
|
|
||||||
newFetching[uri] = true;
|
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
|
||||||
fetching: newFetching,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
reducers[ACTIONS.FETCH_COST_INFO_COMPLETED] = (state, action) => {
|
|
||||||
const { uri, costInfo } = action.data;
|
|
||||||
const newByUri = Object.assign({}, state.byUri);
|
|
||||||
const newFetching = Object.assign({}, state.fetching);
|
|
||||||
|
|
||||||
newByUri[uri] = costInfo;
|
|
||||||
delete newFetching[uri];
|
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
|
||||||
byUri: newByUri,
|
|
||||||
fetching: newFetching,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export function costInfoReducer(state = defaultState, action) {
|
|
||||||
const handler = reducers[action.type];
|
|
||||||
if (handler) return handler(state, action);
|
|
||||||
return state;
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
import { createSelector } from 'reselect';
|
|
||||||
|
|
||||||
export const selectState = state => state.blacklist || {};
|
|
||||||
|
|
||||||
export const selectBlackListedOutpoints = createSelector(
|
|
||||||
selectState,
|
|
||||||
state => state.blackListedOutpoints
|
|
||||||
);
|
|
|
@ -237,20 +237,6 @@ export const makeSelectIsUriResolving = uri =>
|
||||||
resolvingUris => resolvingUris && resolvingUris.indexOf(uri) !== -1
|
resolvingUris => resolvingUris && resolvingUris.indexOf(uri) !== -1
|
||||||
);
|
);
|
||||||
|
|
||||||
export const selectFeaturedUris = createSelector(selectState, state => state.featuredUris);
|
|
||||||
|
|
||||||
export const selectFetchingFeaturedUris = createSelector(
|
|
||||||
selectState,
|
|
||||||
state => state.fetchingFeaturedContent
|
|
||||||
);
|
|
||||||
|
|
||||||
export const selectTrendingUris = createSelector(selectState, state => state.trendingUris);
|
|
||||||
|
|
||||||
export const selectFetchingTrendingUris = createSelector(
|
|
||||||
selectState,
|
|
||||||
state => state.fetchingTrendingContent
|
|
||||||
);
|
|
||||||
|
|
||||||
export const selectPlayingUri = createSelector(selectState, state => state.playingUri);
|
export const selectPlayingUri = createSelector(selectState, state => state.playingUri);
|
||||||
|
|
||||||
export const selectChannelClaimCounts = createSelector(
|
export const selectChannelClaimCounts = createSelector(
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
import { createSelector } from 'reselect';
|
|
||||||
import { selectCurrentParams } from 'redux/selectors/navigation';
|
|
||||||
|
|
||||||
export const selectState = state => state.costInfo || {};
|
|
||||||
|
|
||||||
export const selectAllCostInfoByUri = createSelector(selectState, state => state.byUri || {});
|
|
||||||
|
|
||||||
export const makeSelectCostInfoForUri = uri =>
|
|
||||||
createSelector(selectAllCostInfoByUri, costInfos => costInfos && costInfos[uri]);
|
|
||||||
|
|
||||||
export const selectCostForCurrentPageUri = createSelector(
|
|
||||||
selectAllCostInfoByUri,
|
|
||||||
selectCurrentParams,
|
|
||||||
(costInfo, params) => (params.uri && costInfo[params.uri] ? costInfo[params.uri].cost : undefined)
|
|
||||||
);
|
|
||||||
|
|
||||||
export const selectFetchingCostInfo = createSelector(selectState, state => state.fetching || {});
|
|
||||||
|
|
||||||
export const makeSelectFetchingCostInfoForUri = uri =>
|
|
||||||
createSelector(selectFetchingCostInfo, fetchingByUri => fetchingByUri && fetchingByUri[uri]);
|
|
Loading…
Reference in a new issue