Uses timestamps for dates for Claims and Transactions
This commit is contained in:
parent
727d367020
commit
2b94f516eb
3 changed files with 112 additions and 123 deletions
67
dist/bundle.es.js
vendored
67
dist/bundle.es.js
vendored
|
@ -50,7 +50,6 @@ const CHECK_ADDRESS_IS_MINE_COMPLETED = 'CHECK_ADDRESS_IS_MINE_COMPLETED';
|
|||
const SEND_TRANSACTION_STARTED = 'SEND_TRANSACTION_STARTED';
|
||||
const SEND_TRANSACTION_COMPLETED = 'SEND_TRANSACTION_COMPLETED';
|
||||
const SEND_TRANSACTION_FAILED = 'SEND_TRANSACTION_FAILED';
|
||||
const FETCH_BLOCK_SUCCESS = 'FETCH_BLOCK_SUCCESS';
|
||||
const SUPPORT_TRANSACTION_STARTED = 'SUPPORT_TRANSACTION_STARTED';
|
||||
const SUPPORT_TRANSACTION_COMPLETED = 'SUPPORT_TRANSACTION_COMPLETED';
|
||||
const SUPPORT_TRANSACTION_FAILED = 'SUPPORT_TRANSACTION_FAILED';
|
||||
|
@ -262,7 +261,6 @@ var action_types = /*#__PURE__*/Object.freeze({
|
|||
SEND_TRANSACTION_STARTED: SEND_TRANSACTION_STARTED,
|
||||
SEND_TRANSACTION_COMPLETED: SEND_TRANSACTION_COMPLETED,
|
||||
SEND_TRANSACTION_FAILED: SEND_TRANSACTION_FAILED,
|
||||
FETCH_BLOCK_SUCCESS: FETCH_BLOCK_SUCCESS,
|
||||
SUPPORT_TRANSACTION_STARTED: SUPPORT_TRANSACTION_STARTED,
|
||||
SUPPORT_TRANSACTION_COMPLETED: SUPPORT_TRANSACTION_COMPLETED,
|
||||
SUPPORT_TRANSACTION_FAILED: SUPPORT_TRANSACTION_FAILED,
|
||||
|
@ -1233,6 +1231,15 @@ const makeSelectMetadataForUri = uri => reselect.createSelector(makeSelectClaimF
|
|||
|
||||
const makeSelectTitleForUri = uri => reselect.createSelector(makeSelectMetadataForUri(uri), metadata => metadata && metadata.title);
|
||||
|
||||
const makeSelectDateForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => {
|
||||
const timestamp = claim && claim.timestamp ? claim.timestamp * 1000 : undefined;
|
||||
if (!timestamp) {
|
||||
return undefined;
|
||||
}
|
||||
const dateObj = new Date(timestamp);
|
||||
return dateObj;
|
||||
});
|
||||
|
||||
const makeSelectContentTypeForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => {
|
||||
const source = claim && claim.value && claim.value.source;
|
||||
return source ? source.media_type : undefined;
|
||||
|
@ -1510,26 +1517,6 @@ const selectBlocks = reselect.createSelector(selectState$2, state => state.block
|
|||
|
||||
const selectCurrentHeight = reselect.createSelector(selectState$2, state => state.latestBlock);
|
||||
|
||||
const makeSelectBlockDate = block => reselect.createSelector(selectBlocks, selectCurrentHeight, (blocks, latestBlock) => {
|
||||
// If we have the block data, look at the actual date,
|
||||
// If not, try to simulate it based on 2.5 minute blocks
|
||||
// Adding this on 11/7/2018 because caling block_show for every claim is causing
|
||||
// performance issues.
|
||||
if (blocks && blocks[block]) {
|
||||
return new Date(blocks[block].time * 1000);
|
||||
}
|
||||
|
||||
// Pending claim
|
||||
if (block < 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const difference = latestBlock - block;
|
||||
const msSincePublish = difference * 2.5 * 60 * 1000; // Number of blocks * 2.5 minutes in ms
|
||||
const publishDate = Date.now() - msSincePublish;
|
||||
return new Date(publishDate);
|
||||
});
|
||||
|
||||
const selectTransactionListFilter = reselect.createSelector(selectState$2, state => state.transactionListFilter || '');
|
||||
|
||||
function formatCredits(amount, precision) {
|
||||
|
@ -1631,17 +1618,6 @@ function doFetchTransactions() {
|
|||
};
|
||||
}
|
||||
|
||||
function doFetchBlock(height) {
|
||||
return dispatch => {
|
||||
lbryProxy.block_show({ height }).then(block => {
|
||||
dispatch({
|
||||
type: FETCH_BLOCK_SUCCESS,
|
||||
data: { block }
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function doGetNewAddress() {
|
||||
return dispatch => {
|
||||
dispatch({
|
||||
|
@ -2235,14 +2211,18 @@ const selectSearchDownloadUris = query => reselect.createSelector(selectFileInfo
|
|||
});
|
||||
|
||||
return downloadResultsFromQuery.length ? downloadResultsFromQuery.map(fileInfo => {
|
||||
const { channel_name: channelName, claim_id: claimId, claim_name: claimName } = fileInfo;
|
||||
const {
|
||||
channel_name: channelName,
|
||||
claim_id: claimId,
|
||||
claim_name: claimName
|
||||
} = fileInfo;
|
||||
|
||||
const uriParams = {};
|
||||
|
||||
if (channelName) {
|
||||
const claim = claimsById[claimId];
|
||||
if (claim && claim.value) {
|
||||
uriParams.claimId = claim.value.publisherSignature.certificateId;
|
||||
if (claim && claim.signing_channel) {
|
||||
uriParams.claimId = claim.signing_channel.claim_id;
|
||||
} else {
|
||||
uriParams.claimId = claimId;
|
||||
}
|
||||
|
@ -3256,18 +3236,6 @@ reducers$2[SUPPORT_TRANSACTION_FAILED] = (state, action) => Object.assign({}, st
|
|||
sendingSupport: false
|
||||
});
|
||||
|
||||
reducers$2[FETCH_BLOCK_SUCCESS] = (state, action) => {
|
||||
const {
|
||||
block,
|
||||
block: { height }
|
||||
} = action.data;
|
||||
const blocks = Object.assign({}, state.blocks);
|
||||
|
||||
blocks[height] = block;
|
||||
|
||||
return Object.assign({}, state, { blocks });
|
||||
};
|
||||
|
||||
reducers$2[WALLET_STATUS_COMPLETED] = (state, action) => Object.assign({}, state, {
|
||||
walletIsEncrypted: action.result
|
||||
});
|
||||
|
@ -3442,7 +3410,6 @@ exports.doCreateChannel = doCreateChannel;
|
|||
exports.doDismissError = doDismissError;
|
||||
exports.doDismissToast = doDismissToast;
|
||||
exports.doError = doError;
|
||||
exports.doFetchBlock = doFetchBlock;
|
||||
exports.doFetchChannelListMine = doFetchChannelListMine;
|
||||
exports.doFetchClaimListMine = doFetchClaimListMine;
|
||||
exports.doFetchClaimsByChannel = doFetchClaimsByChannel;
|
||||
|
@ -3478,7 +3445,6 @@ exports.formatFullPrice = formatFullPrice;
|
|||
exports.isNameValid = isNameValid;
|
||||
exports.isURIClaimable = isURIClaimable;
|
||||
exports.isURIValid = isURIValid;
|
||||
exports.makeSelectBlockDate = makeSelectBlockDate;
|
||||
exports.makeSelectChannelForClaimUri = makeSelectChannelForClaimUri;
|
||||
exports.makeSelectClaimForUri = makeSelectClaimForUri;
|
||||
exports.makeSelectClaimIsMine = makeSelectClaimIsMine;
|
||||
|
@ -3489,6 +3455,7 @@ exports.makeSelectClaimsInChannelForPage = makeSelectClaimsInChannelForPage;
|
|||
exports.makeSelectContentPositionForUri = makeSelectContentPositionForUri;
|
||||
exports.makeSelectContentTypeForUri = makeSelectContentTypeForUri;
|
||||
exports.makeSelectCoverForUri = makeSelectCoverForUri;
|
||||
exports.makeSelectDateForUri = makeSelectDateForUri;
|
||||
exports.makeSelectDownloadingForUri = makeSelectDownloadingForUri;
|
||||
exports.makeSelectFetchingChannelClaims = makeSelectFetchingChannelClaims;
|
||||
exports.makeSelectFileInfoForUri = makeSelectFileInfoForUri;
|
||||
|
|
1
dist/flow-typed/Claim.js
vendored
1
dist/flow-typed/Claim.js
vendored
|
@ -31,6 +31,7 @@ declare type GenericClaim = {
|
|||
decoded_claim: boolean, // claim made in accordance with sdk protobuf types
|
||||
depth: number, // confirmations since tx
|
||||
effective_amount: number, // bid amount + supports
|
||||
timestamp?: number, // date of transaction
|
||||
has_signature: boolean,
|
||||
height: number, // block height the tx was confirmed
|
||||
hex: string, // `value` hex encoded
|
||||
|
|
|
@ -26,11 +26,15 @@ export const selectIsFetchingFileListDownloadedOrPublished = createSelector(
|
|||
);
|
||||
|
||||
export const makeSelectFileInfoForUri = uri =>
|
||||
createSelector(selectClaimsByUri, selectFileInfosByOutpoint, (claims, byOutpoint) => {
|
||||
const claim = claims[uri];
|
||||
const outpoint = claim ? `${claim.txid}:${claim.nout}` : undefined;
|
||||
return outpoint ? byOutpoint[outpoint] : undefined;
|
||||
});
|
||||
createSelector(
|
||||
selectClaimsByUri,
|
||||
selectFileInfosByOutpoint,
|
||||
(claims, byOutpoint) => {
|
||||
const claim = claims[uri];
|
||||
const outpoint = claim ? `${claim.txid}:${claim.nout}` : undefined;
|
||||
return outpoint ? byOutpoint[outpoint] : undefined;
|
||||
}
|
||||
);
|
||||
|
||||
export const selectDownloadingByOutpoint = createSelector(
|
||||
selectState,
|
||||
|
@ -47,10 +51,16 @@ export const makeSelectDownloadingForUri = uri =>
|
|||
}
|
||||
);
|
||||
|
||||
export const selectUrisLoading = createSelector(selectState, state => state.urisLoading || {});
|
||||
export const selectUrisLoading = createSelector(
|
||||
selectState,
|
||||
state => state.urisLoading || {}
|
||||
);
|
||||
|
||||
export const makeSelectLoadingForUri = uri =>
|
||||
createSelector(selectUrisLoading, byUri => byUri && byUri[uri]);
|
||||
createSelector(
|
||||
selectUrisLoading,
|
||||
byUri => byUri && byUri[uri]
|
||||
);
|
||||
|
||||
export const selectFileInfosDownloaded = createSelector(
|
||||
selectFileInfosByOutpoint,
|
||||
|
@ -93,93 +103,103 @@ export const selectDownloadingFileInfos = createSelector(
|
|||
}
|
||||
);
|
||||
|
||||
export const selectTotalDownloadProgress = createSelector(selectDownloadingFileInfos, fileInfos => {
|
||||
const progress = [];
|
||||
export const selectTotalDownloadProgress = createSelector(
|
||||
selectDownloadingFileInfos,
|
||||
fileInfos => {
|
||||
const progress = [];
|
||||
|
||||
fileInfos.forEach(fileInfo => {
|
||||
progress.push((fileInfo.written_bytes / fileInfo.total_bytes) * 100);
|
||||
});
|
||||
fileInfos.forEach(fileInfo => {
|
||||
progress.push((fileInfo.written_bytes / fileInfo.total_bytes) * 100);
|
||||
});
|
||||
|
||||
const totalProgress = progress.reduce((a, b) => a + b, 0);
|
||||
const totalProgress = progress.reduce((a, b) => a + b, 0);
|
||||
|
||||
if (fileInfos.length > 0) return totalProgress / fileInfos.length / 100.0;
|
||||
return -1;
|
||||
});
|
||||
if (fileInfos.length > 0) return totalProgress / fileInfos.length / 100.0;
|
||||
return -1;
|
||||
}
|
||||
);
|
||||
|
||||
export const selectSearchDownloadUris = query =>
|
||||
createSelector(selectFileInfosDownloaded, selectClaimsById, (fileInfos, claimsById) => {
|
||||
if (!query || !fileInfos.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const queryParts = query.toLowerCase().split(' ');
|
||||
const searchQueryDictionary = {};
|
||||
queryParts.forEach(subQuery => {
|
||||
searchQueryDictionary[subQuery] = subQuery;
|
||||
});
|
||||
|
||||
const arrayContainsQueryPart = array => {
|
||||
for (let i = 0; i < array.length; i += 1) {
|
||||
const subQuery = array[i];
|
||||
if (searchQueryDictionary[subQuery]) {
|
||||
return true;
|
||||
}
|
||||
createSelector(
|
||||
selectFileInfosDownloaded,
|
||||
selectClaimsById,
|
||||
(fileInfos, claimsById) => {
|
||||
if (!query || !fileInfos.length) {
|
||||
return null;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
const downloadResultsFromQuery = [];
|
||||
fileInfos.forEach(fileInfo => {
|
||||
const { channel_name: channelName, claim_name: claimName, metadata } = fileInfo;
|
||||
const { author, description, title } = metadata;
|
||||
const queryParts = query.toLowerCase().split(' ');
|
||||
const searchQueryDictionary = {};
|
||||
queryParts.forEach(subQuery => {
|
||||
searchQueryDictionary[subQuery] = subQuery;
|
||||
});
|
||||
|
||||
if (channelName) {
|
||||
const lowerCaseChannel = channelName.toLowerCase();
|
||||
const strippedOutChannelName = lowerCaseChannel.slice(1); // trim off the @
|
||||
if (searchQueryDictionary[channelName] || searchQueryDictionary[strippedOutChannelName]) {
|
||||
const arrayContainsQueryPart = array => {
|
||||
for (let i = 0; i < array.length; i += 1) {
|
||||
const subQuery = array[i];
|
||||
if (searchQueryDictionary[subQuery]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
const downloadResultsFromQuery = [];
|
||||
fileInfos.forEach(fileInfo => {
|
||||
const { channel_name: channelName, claim_name: claimName, metadata } = fileInfo;
|
||||
const { author, description, title } = metadata;
|
||||
|
||||
if (channelName) {
|
||||
const lowerCaseChannel = channelName.toLowerCase();
|
||||
const strippedOutChannelName = lowerCaseChannel.slice(1); // trim off the @
|
||||
if (searchQueryDictionary[channelName] || searchQueryDictionary[strippedOutChannelName]) {
|
||||
downloadResultsFromQuery.push(fileInfo);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const nameParts = claimName.toLowerCase().split('-');
|
||||
if (arrayContainsQueryPart(nameParts)) {
|
||||
downloadResultsFromQuery.push(fileInfo);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const nameParts = claimName.toLowerCase().split('-');
|
||||
if (arrayContainsQueryPart(nameParts)) {
|
||||
downloadResultsFromQuery.push(fileInfo);
|
||||
return;
|
||||
}
|
||||
|
||||
const titleParts = title.toLowerCase().split(' ');
|
||||
if (arrayContainsQueryPart(titleParts)) {
|
||||
downloadResultsFromQuery.push(fileInfo);
|
||||
return;
|
||||
}
|
||||
|
||||
if (author) {
|
||||
const authorParts = author.toLowerCase().split(' ');
|
||||
if (arrayContainsQueryPart(authorParts)) {
|
||||
const titleParts = title.toLowerCase().split(' ');
|
||||
if (arrayContainsQueryPart(titleParts)) {
|
||||
downloadResultsFromQuery.push(fileInfo);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (description) {
|
||||
const descriptionParts = description.toLowerCase().split(' ');
|
||||
if (arrayContainsQueryPart(descriptionParts)) {
|
||||
downloadResultsFromQuery.push(fileInfo);
|
||||
if (author) {
|
||||
const authorParts = author.toLowerCase().split(' ');
|
||||
if (arrayContainsQueryPart(authorParts)) {
|
||||
downloadResultsFromQuery.push(fileInfo);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return downloadResultsFromQuery.length
|
||||
? downloadResultsFromQuery.map(fileInfo => {
|
||||
const { channel_name: channelName, claim_id: claimId, claim_name: claimName } = fileInfo;
|
||||
if (description) {
|
||||
const descriptionParts = description.toLowerCase().split(' ');
|
||||
if (arrayContainsQueryPart(descriptionParts)) {
|
||||
downloadResultsFromQuery.push(fileInfo);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return downloadResultsFromQuery.length
|
||||
? downloadResultsFromQuery.map(fileInfo => {
|
||||
const {
|
||||
channel_name: channelName,
|
||||
claim_id: claimId,
|
||||
claim_name: claimName,
|
||||
} = fileInfo;
|
||||
|
||||
const uriParams = {};
|
||||
|
||||
if (channelName) {
|
||||
const claim = claimsById[claimId];
|
||||
if (claim && claim.value) {
|
||||
uriParams.claimId = claim.value.publisherSignature.certificateId;
|
||||
if (claim && claim.signing_channel) {
|
||||
uriParams.claimId = claim.signing_channel.claim_id;
|
||||
} else {
|
||||
uriParams.claimId = claimId;
|
||||
}
|
||||
|
@ -193,8 +213,9 @@ export const selectSearchDownloadUris = query =>
|
|||
const uri = buildURI(uriParams);
|
||||
return uri;
|
||||
})
|
||||
: null;
|
||||
});
|
||||
: null;
|
||||
}
|
||||
);
|
||||
|
||||
export const selectFileListPublishedSort = createSelector(
|
||||
selectState,
|
||||
|
|
Loading…
Reference in a new issue