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
const PAGE_SIZE$1 = 50;
const LATEST_PAGE_SIZE = 20;
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';
@ -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 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) : [];
});
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);
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 => {
dispatch(doFetchSupports());
dispatch({
type: FETCH_TRANSACTIONS_STARTED
});
lbryProxy.utxo_release().then(() => lbryProxy.transaction_list()).then(results => {
debugger;
lbryProxy.utxo_release().then(() => lbryProxy.transaction_list({ page: page, page_size: pageSize })).then(results => {
dispatch({
type: FETCH_TRANSACTIONS_COMPLETED,
data: {
@ -2673,7 +2667,7 @@ function doAbandonClaim(txid, nout) {
// After abandoning, call claim_list to show the claim as abandoned
// Also fetch transactions to show the new abandon transaction
if (isClaim) dispatch(doFetchClaimListMine());
dispatch(doFetchTransactions());
dispatch(doFetchTransactions(1, 2));
};
const abandonParams = {
@ -3624,7 +3618,7 @@ const doCheckPendingPublishes = onConfirmed => (dispatch, getState) => {
let publishCheckInterval;
const checkFileList = () => {
lbryProxy.claim_list().then(claims => {
lbryProxy.stream_list({ page: 1, page_size: 5 }).then(claims => {
// $FlowFixMe
claims.forEach(claim => {
// If it's confirmed, check if it was pending previously
@ -5425,6 +5419,7 @@ exports.makeSelectFilteredTransactionsForPage = makeSelectFilteredTransactionsFo
exports.makeSelectFirstRecommendedFileForUri = makeSelectFirstRecommendedFileForUri;
exports.makeSelectIsFollowingTag = makeSelectIsFollowingTag;
exports.makeSelectIsUriResolving = makeSelectIsUriResolving;
exports.makeSelectLatestTransactions = makeSelectLatestTransactions;
exports.makeSelectLoadingForUri = makeSelectLoadingForUri;
exports.makeSelectMediaTypeForUri = makeSelectMediaTypeForUri;
exports.makeSelectMetadataForUri = makeSelectMetadataForUri;
@ -5524,7 +5519,6 @@ exports.selectPublishFormValues = selectPublishFormValues;
exports.selectPurchaseUriErrorMessage = selectPurchaseUriErrorMessage;
exports.selectPurchasedUris = selectPurchasedUris;
exports.selectReceiveAddress = selectReceiveAddress;
exports.selectRecentTransactions = selectRecentTransactions;
exports.selectReservedBalance = selectReservedBalance;
exports.selectResolvingUris = selectResolvingUris;
exports.selectSearchBarFocused = selectSearchBarFocused;

View file

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

View file

@ -277,7 +277,6 @@ export {
selectSupportsByOutpoint,
selectTotalSupports,
selectTransactionItems,
selectRecentTransactions,
selectHasTransactions,
selectIsFetchingTransactions,
selectIsSendingSupport,
@ -301,6 +300,7 @@ export {
selectWalletUnlockResult,
selectTransactionListFilter,
selectFilteredTransactions,
makeSelectLatestTransactions,
makeSelectFilteredTransactionsForPage,
selectFilteredTransactionCount,
} 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
// Also fetch transactions to show the new abandon transaction
if (isClaim) dispatch(doFetchClaimListMine());
dispatch(doFetchTransactions());
dispatch(doFetchTransactions(1,2));
};
const abandonParams = {
@ -396,7 +396,15 @@ export function doFetchChannelListMine() {
}
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,
}
) {

View file

@ -366,7 +366,7 @@ export const doCheckPendingPublishes = (onConfirmed: Function) => (
let publishCheckInterval;
const checkFileList = () => {
Lbry.claim_list().then(claims => {
Lbry.stream_list( { page: 1, page_size: 5}).then(claims => {
// $FlowFixMe
claims.forEach(claim => {
// 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 => {
dispatch(doFetchSupports());
dispatch({
type: ACTIONS.FETCH_TRANSACTIONS_STARTED,
});
debugger;
Lbry.utxo_release()
.then(() => Lbry.transaction_list())
.then(() => Lbry.transaction_list({ page: page, page_size: pageSize}))
.then(results => {
dispatch({
type: ACTIONS.FETCH_TRANSACTIONS_COMPLETED,

View file

@ -1,6 +1,6 @@
import { createSelector } from 'reselect';
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 || {};
@ -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(
selectTransactionItems,
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(
selectFilteredTransactions,
filteredTransactions => filteredTransactions.length