This commit is contained in:
Sean Yesmunt 2019-11-01 15:08:42 -04:00
parent 2157834ff6
commit 861880a029
9 changed files with 151 additions and 105 deletions

99
dist/bundle.es.js vendored
View file

@ -772,6 +772,7 @@ const Lbry = {
channel_import: params => daemonCallWithResult('channel_import', params), channel_import: params => daemonCallWithResult('channel_import', params),
channel_list: params => daemonCallWithResult('channel_list', params), channel_list: params => daemonCallWithResult('channel_list', params),
stream_abandon: params => daemonCallWithResult('stream_abandon', params), stream_abandon: params => daemonCallWithResult('stream_abandon', params),
stream_list: params => daemonCallWithResult('stream_list', params),
channel_abandon: params => daemonCallWithResult('channel_abandon', params), channel_abandon: params => daemonCallWithResult('channel_abandon', params),
support_create: params => daemonCallWithResult('support_create', params), support_create: params => daemonCallWithResult('support_create', params),
@ -831,16 +832,16 @@ const Lbry = {
// Flow thinks this could be empty, but it will always reuturn a promise // Flow thinks this could be empty, but it will always reuturn a promise
// $FlowFixMe // $FlowFixMe
return Lbry.connectPromise; return Lbry.connectPromise;
} },
};
Lbry.publish = (params = {}) => new Promise((resolve, reject) => { publish: (params = {}) => new Promise((resolve, reject) => {
if (Lbry.overrides.publish) { if (Lbry.overrides.publish) {
Lbry.overrides.publish(params).then(resolve, reject); Lbry.overrides.publish(params).then(resolve, reject);
} else { } else {
apiCall('publish', params, resolve, reject); apiCall('publish', params, resolve, reject);
} }
}); })
};
function checkAndParse(response) { function checkAndParse(response) {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
@ -1703,7 +1704,7 @@ const makeSelectFilteredTransactionsForPage = (page = 1) => reselect.createSelec
}); });
const makeSelectLatestTransactions = reselect.createSelector(selectTransactionItems, transactions => { const makeSelectLatestTransactions = reselect.createSelector(selectTransactionItems, transactions => {
return transactions && transactions.length ? transactions.slice(transactions.length < LATEST_PAGE_SIZE ? transactions.length : LATEST_PAGE_SIZE) : []; return transactions && transactions.length ? transactions.slice(0, LATEST_PAGE_SIZE) : [];
}); });
const selectFilteredTransactionCount = reselect.createSelector(selectFilteredTransactions, filteredTransactions => filteredTransactions.length); const selectFilteredTransactionCount = reselect.createSelector(selectFilteredTransactions, filteredTransactions => filteredTransactions.length);
@ -2172,30 +2173,38 @@ function creditsToString(amount) {
return creditString; return creditString;
} }
let walletBalancePromise = null;
function doUpdateBalance() { function doUpdateBalance() {
return (dispatch, getState) => { return (dispatch, getState) => {
const { const {
wallet: { totalBalance: totalInStore } wallet: { totalBalance: totalInStore }
} = getState(); } = getState();
return lbryProxy.wallet_balance({ reserved_subtotals: true }).then(response => {
const { available, reserved, reserved_subtotals, total } = response;
const { claims, supports, tips } = reserved_subtotals;
const totalFloat = parseFloat(total);
if (totalInStore !== totalFloat) { if (walletBalancePromise === null) {
dispatch({ walletBalancePromise = lbryProxy.wallet_balance({ reserved_subtotals: true }).then(response => {
type: UPDATE_BALANCE, walletBalancePromise = null;
data: {
totalBalance: totalFloat, const { available, reserved, reserved_subtotals, total } = response;
balance: parseFloat(available), const { claims, supports, tips } = reserved_subtotals;
reservedBalance: parseFloat(reserved), const totalFloat = parseFloat(total);
claimsBalance: parseFloat(claims),
supportsBalance: parseFloat(supports), if (totalInStore !== totalFloat) {
tipsBalance: parseFloat(tips) dispatch({
} type: UPDATE_BALANCE,
}); data: {
} totalBalance: totalFloat,
}); balance: parseFloat(available),
reservedBalance: parseFloat(reserved),
claimsBalance: parseFloat(claims),
supportsBalance: parseFloat(supports),
tipsBalance: parseFloat(tips)
}
});
}
});
}
return walletBalancePromise;
}; };
} }
@ -2206,18 +2215,18 @@ function doBalanceSubscribe() {
}; };
} }
function doFetchTransactions(page, pageSize) { function doFetchTransactions(page = 1, pageSize = 99999) {
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({ page: page, page_size: pageSize })).then(results => { lbryProxy.utxo_release().then(() => lbryProxy.transaction_list({ page, page_size: pageSize })).then(result => {
dispatch({ dispatch({
type: FETCH_TRANSACTIONS_COMPLETED, type: FETCH_TRANSACTIONS_COMPLETED,
data: { data: {
transactions: results transactions: result.items
} }
}); });
}); });
@ -2593,13 +2602,15 @@ function doResolveUri(uri) {
return doResolveUris([uri]); return doResolveUris([uri]);
} }
function doFetchClaimListMine() { function doFetchClaimListMine(page = 1, pageSize = 9999) {
return dispatch => { return dispatch => {
dispatch({ dispatch({
type: FETCH_CLAIM_LIST_MINE_STARTED type: FETCH_CLAIM_LIST_MINE_STARTED
}); });
lbryProxy.claim_list().then(claims => { lbryProxy.claim_list({ page, page_size: pageSize }).then(result => {
const claims = result.items;
dispatch({ dispatch({
type: FETCH_CLAIM_LIST_MINE_COMPLETED, type: FETCH_CLAIM_LIST_MINE_COMPLETED,
data: { data: {
@ -2664,10 +2675,12 @@ function doAbandonClaim(txid, nout) {
message: abandonMessage message: abandonMessage
})); }));
// After abandoning, call claim_list to show the claim as abandoned // After abandoning, fetch transactions to show the new abandon transaction
// Also fetch transactions to show the new abandon transaction // Only fetch the latest few transactions since we don't care about old ones
if (isClaim) dispatch(doFetchClaimListMine()); // Not very robust, but better than calling the entire list for large wallets
dispatch(doFetchTransactions(1, 2)); const page = 1;
const pageSize = 10;
dispatch(doFetchTransactions(page, pageSize));
}; };
const abandonParams = { const abandonParams = {
@ -2867,7 +2880,9 @@ function doFetchChannelListMine() {
} }
function doClaimSearch(options = { function doClaimSearch(options = {
page_size: 10 no_totals: true,
page_size: 10,
page: 1
}) { }) {
const query = createNormalizedClaimSearchKey(options); const query = createNormalizedClaimSearchKey(options);
return dispatch => { return dispatch => {
@ -3431,6 +3446,7 @@ const doUploadThumbnail = (filePath, thumbnailBlob, fsAdapter, fs, path) => disp
const name = makeid(); const name = makeid();
const file = thumbnailBlob || thumbnail && new File([thumbnail], fileName, { type: fileType }); const file = thumbnailBlob || thumbnail && new File([thumbnail], fileName, { type: fileType });
data.append('name', name); data.append('name', name);
// $FlowFixMe
data.append('file', file); data.append('file', file);
return fetch(SPEECH_PUBLISH, { return fetch(SPEECH_PUBLISH, {
@ -3618,8 +3634,9 @@ const doCheckPendingPublishes = onConfirmed => (dispatch, getState) => {
let publishCheckInterval; let publishCheckInterval;
const checkFileList = () => { const checkFileList = () => {
lbryProxy.stream_list({ page: 1, page_size: 5 }).then(claims => { lbryProxy.stream_list({ page: 1, page_size: 10 }).then(result => {
// $FlowFixMe const claims = result.items;
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
if (claim.confirmations > 0 && pendingById[claim.claim_id]) { if (claim.confirmations > 0 && pendingById[claim.claim_id]) {

View file

@ -107,7 +107,7 @@ declare type ClaimSearchResponse = {
}; };
declare type ClaimListResponse = { declare type ClaimListResponse = {
claims: Array<ChannelClaim | Claim>, items: Array<ChannelClaim | Claim>,
}; };
declare type ChannelCreateResponse = GenericTxResponse & { declare type ChannelCreateResponse = GenericTxResponse & {
@ -125,7 +125,7 @@ declare type ChannelListResponse = Array<ChannelClaim>;
declare type FileListResponse = Array<FileListItem>; declare type FileListResponse = Array<FileListItem>;
declare type TxListResponse = Array<Transaction>; declare type TxListResponse = { items: Array<Transaction> };
declare type BlobListResponse = Array<string>; declare type BlobListResponse = Array<string>;
@ -146,6 +146,8 @@ declare type SyncApplyResponse = {
declare type SupportAbandonResponse = GenericTxResponse; declare type SupportAbandonResponse = GenericTxResponse;
declare type StreamListResponse = { items: Array<StreamClaim> };
// //
// Types used in the generic Lbry object that is exported // Types used in the generic Lbry object that is exported
// //
@ -168,7 +170,7 @@ declare type LbryTypes = {
version: () => Promise<VersionResponse>, version: () => Promise<VersionResponse>,
resolve: (params: {}) => Promise<ResolveResponse>, resolve: (params: {}) => Promise<ResolveResponse>,
get: (params: {}) => Promise<GetResponse>, get: (params: {}) => Promise<GetResponse>,
publish?: (params: {}) => Promise<PublishResponse>, publish: (params: {}) => Promise<PublishResponse>,
claim_search: (params: {}) => Promise<ClaimSearchResponse>, claim_search: (params: {}) => Promise<ClaimSearchResponse>,
claim_list: (params?: {}) => Promise<ClaimListResponse>, claim_list: (params?: {}) => Promise<ClaimListResponse>,
@ -177,6 +179,7 @@ declare type LbryTypes = {
channel_import: (params: {}) => Promise<string>, channel_import: (params: {}) => Promise<string>,
channel_list: () => Promise<ChannelListResponse>, channel_list: () => Promise<ChannelListResponse>,
stream_abandon: (params: {}) => Promise<GenericTxResponse>, stream_abandon: (params: {}) => Promise<GenericTxResponse>,
stream_list: (params: {}) => Promise<StreamListResponse>,
channel_abandon: (params: {}) => Promise<GenericTxResponse>, channel_abandon: (params: {}) => Promise<GenericTxResponse>,
support_create: (params: {}) => Promise<GenericTxResponse>, support_create: (params: {}) => Promise<GenericTxResponse>,

9
flow-typed/Lbry.js vendored
View file

@ -107,7 +107,7 @@ declare type ClaimSearchResponse = {
}; };
declare type ClaimListResponse = { declare type ClaimListResponse = {
claims: Array<ChannelClaim | Claim>, items: Array<ChannelClaim | Claim>,
}; };
declare type ChannelCreateResponse = GenericTxResponse & { declare type ChannelCreateResponse = GenericTxResponse & {
@ -125,7 +125,7 @@ declare type ChannelListResponse = Array<ChannelClaim>;
declare type FileListResponse = Array<FileListItem>; declare type FileListResponse = Array<FileListItem>;
declare type TxListResponse = Array<Transaction>; declare type TxListResponse = { items: Array<Transaction> };
declare type BlobListResponse = Array<string>; declare type BlobListResponse = Array<string>;
@ -146,6 +146,8 @@ declare type SyncApplyResponse = {
declare type SupportAbandonResponse = GenericTxResponse; declare type SupportAbandonResponse = GenericTxResponse;
declare type StreamListResponse = { items: Array<StreamClaim> };
// //
// Types used in the generic Lbry object that is exported // Types used in the generic Lbry object that is exported
// //
@ -168,7 +170,7 @@ declare type LbryTypes = {
version: () => Promise<VersionResponse>, version: () => Promise<VersionResponse>,
resolve: (params: {}) => Promise<ResolveResponse>, resolve: (params: {}) => Promise<ResolveResponse>,
get: (params: {}) => Promise<GetResponse>, get: (params: {}) => Promise<GetResponse>,
publish?: (params: {}) => Promise<PublishResponse>, publish: (params: {}) => Promise<PublishResponse>,
claim_search: (params: {}) => Promise<ClaimSearchResponse>, claim_search: (params: {}) => Promise<ClaimSearchResponse>,
claim_list: (params?: {}) => Promise<ClaimListResponse>, claim_list: (params?: {}) => Promise<ClaimListResponse>,
@ -177,6 +179,7 @@ declare type LbryTypes = {
channel_import: (params: {}) => Promise<string>, channel_import: (params: {}) => Promise<string>,
channel_list: () => Promise<ChannelListResponse>, channel_list: () => Promise<ChannelListResponse>,
stream_abandon: (params: {}) => Promise<GenericTxResponse>, stream_abandon: (params: {}) => Promise<GenericTxResponse>,
stream_list: (params: {}) => Promise<StreamListResponse>,
channel_abandon: (params: {}) => Promise<GenericTxResponse>, channel_abandon: (params: {}) => Promise<GenericTxResponse>,
support_create: (params: {}) => Promise<GenericTxResponse>, support_create: (params: {}) => Promise<GenericTxResponse>,

View file

@ -82,6 +82,7 @@ const Lbry: LbryTypes = {
channel_import: params => daemonCallWithResult('channel_import', params), channel_import: params => daemonCallWithResult('channel_import', params),
channel_list: params => daemonCallWithResult('channel_list', params), channel_list: params => daemonCallWithResult('channel_list', params),
stream_abandon: params => daemonCallWithResult('stream_abandon', params), stream_abandon: params => daemonCallWithResult('stream_abandon', params),
stream_list: params => daemonCallWithResult('stream_list', params),
channel_abandon: params => daemonCallWithResult('channel_abandon', params), channel_abandon: params => daemonCallWithResult('channel_abandon', params),
support_create: params => daemonCallWithResult('support_create', params), support_create: params => daemonCallWithResult('support_create', params),
@ -144,16 +145,16 @@ const Lbry: LbryTypes = {
// $FlowFixMe // $FlowFixMe
return Lbry.connectPromise; return Lbry.connectPromise;
}, },
};
Lbry.publish = (params = {}) => publish: (params = {}) =>
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
if (Lbry.overrides.publish) { if (Lbry.overrides.publish) {
Lbry.overrides.publish(params).then(resolve, reject); Lbry.overrides.publish(params).then(resolve, reject);
} else { } else {
apiCall('publish', params, resolve, reject); apiCall('publish', params, resolve, reject);
} }
}); }),
};
function checkAndParse(response) { function checkAndParse(response) {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {

View file

@ -94,13 +94,15 @@ export function doResolveUri(uri: string) {
return doResolveUris([uri]); return doResolveUris([uri]);
} }
export function doFetchClaimListMine() { export function doFetchClaimListMine(page: number = 1, pageSize: number = 9999) {
return (dispatch: Dispatch) => { return (dispatch: Dispatch) => {
dispatch({ dispatch({
type: ACTIONS.FETCH_CLAIM_LIST_MINE_STARTED, type: ACTIONS.FETCH_CLAIM_LIST_MINE_STARTED,
}); });
Lbry.claim_list().then((claims: ClaimListResponse) => { Lbry.claim_list({ page, page_size: pageSize }).then((result: ClaimListResponse) => {
const claims = result.items;
dispatch({ dispatch({
type: ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED, type: ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED,
data: { data: {
@ -175,10 +177,12 @@ export function doAbandonClaim(txid: string, nout: number) {
}) })
); );
// After abandoning, call claim_list to show the claim as abandoned // After abandoning, fetch transactions to show the new abandon transaction
// Also fetch transactions to show the new abandon transaction // Only fetch the latest few transactions since we don't care about old ones
if (isClaim) dispatch(doFetchClaimListMine()); // Not very robust, but better than calling the entire list for large wallets
dispatch(doFetchTransactions(1,2)); const page = 1;
const pageSize = 10;
dispatch(doFetchTransactions(page, pageSize));
}; };
const abandonParams = { const abandonParams = {
@ -396,7 +400,8 @@ export function doFetchChannelListMine() {
} }
export function doClaimSearch( export function doClaimSearch(
options: { page_size: number, options: {
page_size: number,
page: number, page: number,
no_totals: boolean, no_totals: boolean,
any_tags?: Array<string>, any_tags?: Array<string>,
@ -404,8 +409,11 @@ export function doClaimSearch(
not_channel_ids?: Array<string>, not_channel_ids?: Array<string>,
not_tags?: Array<string>, not_tags?: Array<string>,
order_by?: Array<string>, order_by?: Array<string>,
release_time?: string, } = { release_time?: string,
} = {
no_totals: true,
page_size: 10, page_size: 10,
page: 1,
} }
) { ) {
const query = createNormalizedClaimSearchKey(options); const query = createNormalizedClaimSearchKey(options);

View file

@ -145,8 +145,10 @@ export const doUploadThumbnail = (
const data = new FormData(); const data = new FormData();
const name = makeid(); const name = makeid();
const file = thumbnailBlob || (thumbnail && new File([thumbnail], fileName, { type: fileType })); const file =
thumbnailBlob || (thumbnail && new File([thumbnail], fileName, { type: fileType }));
data.append('name', name); data.append('name', name);
// $FlowFixMe
data.append('file', file); data.append('file', file);
return fetch(SPEECH_PUBLISH, { return fetch(SPEECH_PUBLISH, {
@ -275,7 +277,9 @@ export const doPublish = (success: Function, fail: Function) => (
} }
// get the claim id from the channel name, we will use that instead // get the claim id from the channel name, we will use that instead
const namedChannelClaim = myChannels ? myChannels.find(myChannel => myChannel.name === channel) : null; const namedChannelClaim = myChannels
? myChannels.find(myChannel => myChannel.name === channel)
: null;
const channelId = namedChannelClaim ? namedChannelClaim.claim_id : ''; const channelId = namedChannelClaim ? namedChannelClaim.claim_id : '';
const publishPayload: { const publishPayload: {
@ -336,7 +340,7 @@ export const doPublish = (success: Function, fail: Function) => (
} }
if (myClaimForUri && myClaimForUri.value && myClaimForUri.value.locations) { if (myClaimForUri && myClaimForUri.value && myClaimForUri.value.locations) {
publishPayload.locations = myClaimForUri.value.locations; publishPayload.locations = myClaimForUri.value.locations;
} }
if (!contentIsFree && fee && (fee.currency && Number(fee.amount) > 0)) { if (!contentIsFree && fee && (fee.currency && Number(fee.amount) > 0)) {
@ -366,8 +370,9 @@ export const doCheckPendingPublishes = (onConfirmed: Function) => (
let publishCheckInterval; let publishCheckInterval;
const checkFileList = () => { const checkFileList = () => {
Lbry.stream_list( { page: 1, page_size: 5}).then(claims => { Lbry.stream_list({ page: 1, page_size: 10 }).then(result => {
// $FlowFixMe const claims = result.items;
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
if (claim.confirmations > 0 && pendingById[claim.claim_id]) { if (claim.confirmations > 0 && pendingById[claim.claim_id]) {

View file

@ -5,30 +5,38 @@ import { selectBalance } from 'redux/selectors/wallet';
import { creditsToString } from 'util/format-credits'; import { creditsToString } from 'util/format-credits';
import { selectMyClaimsRaw } from 'redux/selectors/claims'; import { selectMyClaimsRaw } from 'redux/selectors/claims';
let walletBalancePromise = null;
export function doUpdateBalance() { export function doUpdateBalance() {
return (dispatch, getState) => { return (dispatch, getState) => {
const { const {
wallet: { totalBalance: totalInStore }, wallet: { totalBalance: totalInStore },
} = getState(); } = getState();
return Lbry.wallet_balance({ reserved_subtotals: true }).then(response => {
const { available, reserved, reserved_subtotals, total } = response;
const { claims, supports, tips } = reserved_subtotals;
const totalFloat = parseFloat(total);
if (totalInStore !== totalFloat) { if (walletBalancePromise === null) {
dispatch({ walletBalancePromise = Lbry.wallet_balance({ reserved_subtotals: true }).then(response => {
type: ACTIONS.UPDATE_BALANCE, walletBalancePromise = null;
data: {
totalBalance: totalFloat, const { available, reserved, reserved_subtotals, total } = response;
balance: parseFloat(available), const { claims, supports, tips } = reserved_subtotals;
reservedBalance: parseFloat(reserved), const totalFloat = parseFloat(total);
claimsBalance: parseFloat(claims),
supportsBalance: parseFloat(supports), if (totalInStore !== totalFloat) {
tipsBalance: parseFloat(tips), dispatch({
}, type: ACTIONS.UPDATE_BALANCE,
}); data: {
} totalBalance: totalFloat,
}); balance: parseFloat(available),
reservedBalance: parseFloat(reserved),
claimsBalance: parseFloat(claims),
supportsBalance: parseFloat(supports),
tipsBalance: parseFloat(tips),
},
});
}
});
}
return walletBalancePromise;
}; };
} }
@ -39,20 +47,20 @@ export function doBalanceSubscribe() {
}; };
} }
export function doFetchTransactions(page, pageSize) { export function doFetchTransactions(page = 1, pageSize = 99999) {
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({ page: page, page_size: pageSize})) .then(() => Lbry.transaction_list({ page, page_size: pageSize }))
.then(results => { .then(result => {
dispatch({ dispatch({
type: ACTIONS.FETCH_TRANSACTIONS_COMPLETED, type: ACTIONS.FETCH_TRANSACTIONS_COMPLETED,
data: { data: {
transactions: results, transactions: result.items,
}, },
}); });
}); });

View file

@ -285,7 +285,7 @@ export const selectFilteredTransactions = createSelector(
} }
); );
export const makeSelectFilteredTransactionsForPage = (page: number = 1): Array<any> => export const makeSelectFilteredTransactionsForPage = (page = 1) =>
createSelector( createSelector(
selectFilteredTransactions, selectFilteredTransactions,
filteredTransactions => { filteredTransactions => {
@ -297,14 +297,12 @@ export const makeSelectFilteredTransactionsForPage = (page: number = 1): Array<a
} }
); );
export const makeSelectLatestTransactions = createSelector( export const makeSelectLatestTransactions = createSelector(
selectTransactionItems, selectTransactionItems,
(transactions) => { transactions => {
return transactions && transactions.length return transactions && transactions.length ? transactions.slice(0, LATEST_PAGE_SIZE) : [];
? transactions.slice( transactions.length < LATEST_PAGE_SIZE ? transactions.length : LATEST_PAGE_SIZE ) }
: []; );
}
);
export const selectFilteredTransactionCount = createSelector( export const selectFilteredTransactionCount = createSelector(
selectFilteredTransactions, selectFilteredTransactions,

View file

@ -23,7 +23,7 @@ export const isClaimNsfw = (claim: Claim): boolean => {
return false; return false;
}; };
export function createNormalizedClaimSearchKey(options: { page?: number, release_time?: string }) { export function createNormalizedClaimSearchKey(options: { page: number, release_time?: string }) {
// Ignore page because we don't care what the last page searched was, we want everything // Ignore page because we don't care what the last page searched was, we want everything
// Ignore release_time because that will change depending on when you call claim_search ex: release_time: ">12344567" // Ignore release_time because that will change depending on when you call claim_search ex: release_time: ">12344567"
const { page: optionToIgnoreForQuery, release_time: anotherToIgnore, ...rest } = options; const { page: optionToIgnoreForQuery, release_time: anotherToIgnore, ...rest } = options;
@ -31,20 +31,23 @@ export function createNormalizedClaimSearchKey(options: { page?: number, release
return query; return query;
} }
export function concatClaims(claimList: Array<Claim> = [], concatClaimList: Array<any> = []): Array<Claim> { export function concatClaims(
claimList: Array<Claim> = [],
concatClaimList: Array<any> = []
): Array<Claim> {
if (!claimList || claimList.length === 0) { if (!claimList || claimList.length === 0) {
if (!concatClaimList) { if (!concatClaimList) {
return []; return [];
} }
return concatClaimList.slice(); return concatClaimList.slice();
} }
const claims = claimList.slice(); const claims = claimList.slice();
concatClaimList.forEach(claim => { concatClaimList.forEach(claim => {
if (!claims.some(item => item.claim_id === claim.claim_id)) { if (!claims.some(item => item.claim_id === claim.claim_id)) {
claims.push(claim); claims.push(claim);
} }
}); });
return claims; return claims;
} }