WIP API improvements

This commit is contained in:
Thomas Zarebczan 2019-11-01 13:17:55 -04:00
parent 130edee41c
commit 2157834ff6
7 changed files with 39 additions and 42 deletions

32
dist/bundle.es.js vendored
View file

@ -657,9 +657,11 @@ var transaction_types = /*#__PURE__*/Object.freeze({
// PAGE SIZE // PAGE SIZE
const PAGE_SIZE$1 = 50; const PAGE_SIZE$1 = 50;
const LATEST_PAGE_SIZE = 20;
var transaction_list = /*#__PURE__*/Object.freeze({ var transaction_list = /*#__PURE__*/Object.freeze({
PAGE_SIZE: PAGE_SIZE$1 PAGE_SIZE: PAGE_SIZE$1,
LATEST_PAGE_SIZE: LATEST_PAGE_SIZE
}); });
const SPEECH_STATUS = 'https://spee.ch/api/config/site/publishing'; const SPEECH_STATUS = 'https://spee.ch/api/config/site/publishing';
@ -1664,18 +1666,6 @@ const selectTransactionItems = reselect.createSelector(selectTransactionsById, b
}); });
}); });
const selectRecentTransactions = reselect.createSelector(selectTransactionItems, transactions => {
const threshold = new Date();
threshold.setDate(threshold.getDate() - 7);
return transactions.filter(transaction => {
if (!transaction.date) {
return true; // pending transaction
}
return transaction.date > threshold;
});
});
const selectHasTransactions = reselect.createSelector(selectTransactionItems, transactions => transactions && transactions.length > 0); const selectHasTransactions = reselect.createSelector(selectTransactionItems, transactions => transactions && transactions.length > 0);
const selectIsFetchingTransactions = reselect.createSelector(selectState$1, state => state.fetchingTransactions); const selectIsFetchingTransactions = reselect.createSelector(selectState$1, state => state.fetchingTransactions);
@ -1712,6 +1702,10 @@ const makeSelectFilteredTransactionsForPage = (page = 1) => reselect.createSelec
return filteredTransactions && filteredTransactions.length ? filteredTransactions.slice(start, end) : []; return filteredTransactions && filteredTransactions.length ? filteredTransactions.slice(start, end) : [];
}); });
const makeSelectLatestTransactions = reselect.createSelector(selectTransactionItems, transactions => {
return transactions && transactions.length ? transactions.slice(transactions.length < LATEST_PAGE_SIZE ? transactions.length : LATEST_PAGE_SIZE) : [];
});
const selectFilteredTransactionCount = reselect.createSelector(selectFilteredTransactions, filteredTransactions => filteredTransactions.length); const selectFilteredTransactionCount = reselect.createSelector(selectFilteredTransactions, filteredTransactions => filteredTransactions.length);
var _extends$3 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _extends$3 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
@ -2212,14 +2206,14 @@ function doBalanceSubscribe() {
}; };
} }
function doFetchTransactions() { function doFetchTransactions(page, pageSize) {
return dispatch => { return dispatch => {
dispatch(doFetchSupports()); dispatch(doFetchSupports());
dispatch({ dispatch({
type: FETCH_TRANSACTIONS_STARTED type: FETCH_TRANSACTIONS_STARTED
}); });
debugger;
lbryProxy.utxo_release().then(() => lbryProxy.transaction_list()).then(results => { lbryProxy.utxo_release().then(() => lbryProxy.transaction_list({ page: page, page_size: pageSize })).then(results => {
dispatch({ dispatch({
type: FETCH_TRANSACTIONS_COMPLETED, type: FETCH_TRANSACTIONS_COMPLETED,
data: { data: {
@ -2673,7 +2667,7 @@ function doAbandonClaim(txid, nout) {
// After abandoning, call claim_list to show the claim as abandoned // After abandoning, call claim_list to show the claim as abandoned
// Also fetch transactions to show the new abandon transaction // Also fetch transactions to show the new abandon transaction
if (isClaim) dispatch(doFetchClaimListMine()); if (isClaim) dispatch(doFetchClaimListMine());
dispatch(doFetchTransactions()); dispatch(doFetchTransactions(1, 2));
}; };
const abandonParams = { const abandonParams = {
@ -3624,7 +3618,7 @@ const doCheckPendingPublishes = onConfirmed => (dispatch, getState) => {
let publishCheckInterval; let publishCheckInterval;
const checkFileList = () => { const checkFileList = () => {
lbryProxy.claim_list().then(claims => { lbryProxy.stream_list({ page: 1, page_size: 5 }).then(claims => {
// $FlowFixMe // $FlowFixMe
claims.forEach(claim => { claims.forEach(claim => {
// If it's confirmed, check if it was pending previously // If it's confirmed, check if it was pending previously
@ -5425,6 +5419,7 @@ exports.makeSelectFilteredTransactionsForPage = makeSelectFilteredTransactionsFo
exports.makeSelectFirstRecommendedFileForUri = makeSelectFirstRecommendedFileForUri; exports.makeSelectFirstRecommendedFileForUri = makeSelectFirstRecommendedFileForUri;
exports.makeSelectIsFollowingTag = makeSelectIsFollowingTag; exports.makeSelectIsFollowingTag = makeSelectIsFollowingTag;
exports.makeSelectIsUriResolving = makeSelectIsUriResolving; exports.makeSelectIsUriResolving = makeSelectIsUriResolving;
exports.makeSelectLatestTransactions = makeSelectLatestTransactions;
exports.makeSelectLoadingForUri = makeSelectLoadingForUri; exports.makeSelectLoadingForUri = makeSelectLoadingForUri;
exports.makeSelectMediaTypeForUri = makeSelectMediaTypeForUri; exports.makeSelectMediaTypeForUri = makeSelectMediaTypeForUri;
exports.makeSelectMetadataForUri = makeSelectMetadataForUri; exports.makeSelectMetadataForUri = makeSelectMetadataForUri;
@ -5524,7 +5519,6 @@ exports.selectPublishFormValues = selectPublishFormValues;
exports.selectPurchaseUriErrorMessage = selectPurchaseUriErrorMessage; exports.selectPurchaseUriErrorMessage = selectPurchaseUriErrorMessage;
exports.selectPurchasedUris = selectPurchasedUris; exports.selectPurchasedUris = selectPurchasedUris;
exports.selectReceiveAddress = selectReceiveAddress; exports.selectReceiveAddress = selectReceiveAddress;
exports.selectRecentTransactions = selectRecentTransactions;
exports.selectReservedBalance = selectReservedBalance; exports.selectReservedBalance = selectReservedBalance;
exports.selectResolvingUris = selectResolvingUris; exports.selectResolvingUris = selectResolvingUris;
exports.selectSearchBarFocused = selectSearchBarFocused; exports.selectSearchBarFocused = selectSearchBarFocused;

View file

@ -1,2 +1,3 @@
// PAGE SIZE // PAGE SIZE
export const PAGE_SIZE = 50; export const PAGE_SIZE = 50;
export const LATEST_PAGE_SIZE = 20;

View file

@ -277,7 +277,6 @@ export {
selectSupportsByOutpoint, selectSupportsByOutpoint,
selectTotalSupports, selectTotalSupports,
selectTransactionItems, selectTransactionItems,
selectRecentTransactions,
selectHasTransactions, selectHasTransactions,
selectIsFetchingTransactions, selectIsFetchingTransactions,
selectIsSendingSupport, selectIsSendingSupport,
@ -301,6 +300,7 @@ export {
selectWalletUnlockResult, selectWalletUnlockResult,
selectTransactionListFilter, selectTransactionListFilter,
selectFilteredTransactions, selectFilteredTransactions,
makeSelectLatestTransactions,
makeSelectFilteredTransactionsForPage, makeSelectFilteredTransactionsForPage,
selectFilteredTransactionCount, selectFilteredTransactionCount,
} from 'redux/selectors/wallet'; } from 'redux/selectors/wallet';

View file

@ -178,7 +178,7 @@ export function doAbandonClaim(txid: string, nout: number) {
// After abandoning, call claim_list to show the claim as abandoned // After abandoning, call claim_list to show the claim as abandoned
// Also fetch transactions to show the new abandon transaction // Also fetch transactions to show the new abandon transaction
if (isClaim) dispatch(doFetchClaimListMine()); if (isClaim) dispatch(doFetchClaimListMine());
dispatch(doFetchTransactions()); dispatch(doFetchTransactions(1,2));
}; };
const abandonParams = { const abandonParams = {
@ -396,7 +396,15 @@ export function doFetchChannelListMine() {
} }
export function doClaimSearch( export function doClaimSearch(
options: { tags?: Array<string>, page?: number, page_size?: number, release_time?: string } = { options: { page_size: number,
page: number,
no_totals: boolean,
any_tags?: Array<string>,
channel_ids?: Array<string>,
not_channel_ids?: Array<string>,
not_tags?: Array<string>,
order_by?: Array<string>,
release_time?: string, } = {
page_size: 10, page_size: 10,
} }
) { ) {

View file

@ -366,7 +366,7 @@ export const doCheckPendingPublishes = (onConfirmed: Function) => (
let publishCheckInterval; let publishCheckInterval;
const checkFileList = () => { const checkFileList = () => {
Lbry.claim_list().then(claims => { Lbry.stream_list( { page: 1, page_size: 5}).then(claims => {
// $FlowFixMe // $FlowFixMe
claims.forEach(claim => { claims.forEach(claim => {
// If it's confirmed, check if it was pending previously // If it's confirmed, check if it was pending previously

View file

@ -39,15 +39,15 @@ export function doBalanceSubscribe() {
}; };
} }
export function doFetchTransactions() { export function doFetchTransactions(page, pageSize) {
return dispatch => { return dispatch => {
dispatch(doFetchSupports()); dispatch(doFetchSupports());
dispatch({ dispatch({
type: ACTIONS.FETCH_TRANSACTIONS_STARTED, type: ACTIONS.FETCH_TRANSACTIONS_STARTED,
}); });
debugger;
Lbry.utxo_release() Lbry.utxo_release()
.then(() => Lbry.transaction_list()) .then(() => Lbry.transaction_list({ page: page, page_size: pageSize}))
.then(results => { .then(results => {
dispatch({ dispatch({
type: ACTIONS.FETCH_TRANSACTIONS_COMPLETED, type: ACTIONS.FETCH_TRANSACTIONS_COMPLETED,

View file

@ -1,6 +1,6 @@
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import * as TRANSACTIONS from 'constants/transaction_types'; import * as TRANSACTIONS from 'constants/transaction_types';
import { PAGE_SIZE } from 'constants/transaction_list'; import { PAGE_SIZE, LATEST_PAGE_SIZE } from 'constants/transaction_list';
export const selectState = state => state.wallet || {}; export const selectState = state => state.wallet || {};
@ -215,21 +215,6 @@ export const selectTransactionItems = createSelector(
} }
); );
export const selectRecentTransactions = createSelector(
selectTransactionItems,
transactions => {
const threshold = new Date();
threshold.setDate(threshold.getDate() - 7);
return transactions.filter(transaction => {
if (!transaction.date) {
return true; // pending transaction
}
return transaction.date > threshold;
});
}
);
export const selectHasTransactions = createSelector( export const selectHasTransactions = createSelector(
selectTransactionItems, selectTransactionItems,
transactions => transactions && transactions.length > 0 transactions => transactions && transactions.length > 0
@ -312,6 +297,15 @@ export const makeSelectFilteredTransactionsForPage = (page: number = 1): Array<a
} }
); );
export const makeSelectLatestTransactions = createSelector(
selectTransactionItems,
(transactions) => {
return transactions && transactions.length
? transactions.slice( transactions.length < LATEST_PAGE_SIZE ? transactions.length : LATEST_PAGE_SIZE )
: [];
}
);
export const selectFilteredTransactionCount = createSelector( export const selectFilteredTransactionCount = createSelector(
selectFilteredTransactions, selectFilteredTransactions,
filteredTransactions => filteredTransactions.length filteredTransactions => filteredTransactions.length