[redesign] moar fixes #1236
8 changed files with 137 additions and 104 deletions
|
@ -22,6 +22,8 @@ type FileInfo = {
|
|||
|
||||
type Props = {
|
||||
hideFilter: boolean,
|
||||
sortByHeight?: boolean,
|
||||
claimsById: Array<{}>,
|
||||
fileInfos: Array<FileInfo>,
|
||||
};
|
||||
|
||||
|
@ -141,21 +143,30 @@ class FileList extends React.PureComponent<Props, State> {
|
|||
const content = [];
|
||||
|
||||
this.sortFunctions[sortBy](fileInfos).forEach(fileInfo => {
|
||||
const { channel_name: channelName, name: claimName, claim_id: claimId } = fileInfo;
|
||||
const {
|
||||
channel_name: channelName,
|
||||
name: claimName,
|
||||
claim_name: claimNameDownloaded,
|
||||
claim_id: claimId,
|
||||
} = fileInfo;
|
||||
const uriParams = {};
|
||||
|
||||
// This is unfortunate
|
||||
// https://github.com/lbryio/lbry/issues/1159
|
||||
const name = claimName || claimNameDownloaded;
|
||||
|
||||
if (channelName) {
|
||||
uriParams.channelName = channelName;
|
||||
uriParams.contentName = claimName;
|
||||
uriParams.contentName = name;
|
||||
uriParams.claimId = this.getChannelSignature(fileInfo);
|
||||
} else {
|
||||
uriParams.claimId = claimId;
|
||||
uriParams.claimName = claimName;
|
||||
uriParams.claimName = name;
|
||||
}
|
||||
|
||||
const uri = buildURI(uriParams);
|
||||
|
||||
content.push(<FileCard key={claimName} uri={uri} showPrice={false} />);
|
||||
content.push(<FileCard key={uri} uri={uri} showPrice={false} />);
|
||||
});
|
||||
|
||||
return (
|
||||
|
|
|
@ -7,9 +7,7 @@ import debounce from 'util/debounce';
|
|||
|
||||
const SEARCH_DEBOUNCE_TIME = 800;
|
||||
|
||||
const NoResults = () => {
|
||||
return <div className="file-tile">{__('No results')}</div>;
|
||||
};
|
||||
const NoResults = () => <div className="file-tile">{__('No results')}</div>;
|
||||
|
||||
type Props = {
|
||||
search: string => void,
|
||||
|
|
|
@ -140,13 +140,20 @@ class PublishForm extends React.PureComponent<Props> {
|
|||
}
|
||||
|
||||
handleFileChange(filePath: string, fileName: string) {
|
||||
const { updatePublishForm, channel } = this.props;
|
||||
const parsedFileName = fileName.replace(regexInvalidURI, '');
|
||||
const uri = this.getNewUri(parsedFileName, channel);
|
||||
const { updatePublishForm, channel, name } = this.props;
|
||||
const newFileParams: {
|
||||
filePath: string,
|
||||
name?: string,
|
||||
uri?: string
|
||||
} = { filePath };
|
||||
|
||||
if (filePath) {
|
||||
updatePublishForm({ filePath, name: parsedFileName, uri });
|
||||
if (!name) {
|
||||
const parsedFileName = fileName.replace(regexInvalidURI, '');
|
||||
const uri = this.getNewUri(parsedFileName, channel);
|
||||
newFileParams.name = parsedFileName;
|
||||
}
|
||||
|
||||
updatePublishForm(newFileParams);
|
||||
}
|
||||
|
||||
handleNameChange(name: ?string) {
|
||||
|
|
|
@ -1,19 +1,33 @@
|
|||
// I'll come back to this
|
||||
/* eslint-disable */
|
||||
// @flow
|
||||
import React from 'react';
|
||||
import Button from 'component/button';
|
||||
import { Form, FormField, Submit } from 'component/common/form';
|
||||
import { Form, FormField, FormRow, Submit } from 'component/common/form';
|
||||
|
||||
class UserEmailVerify extends React.PureComponent {
|
||||
constructor(props) {
|
||||
type Props = {
|
||||
cancelButton: React.Node,
|
||||
errorMessage: ?string,
|
||||
email: string,
|
||||
isPending: boolean,
|
||||
verifyUserEmail: (string, string) => void,
|
||||
verifyUserEmailFailure: string => void,
|
||||
};
|
||||
|
||||
type State = {
|
||||
code: string,
|
||||
};
|
||||
|
||||
class UserEmailVerify extends React.PureComponent<Props, State> {
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
code: '',
|
||||
};
|
||||
|
||||
(this: any).handleSubmit = this.handleSubmit.bind(this);
|
||||
}
|
||||
|
||||
handleCodeChanged(event) {
|
||||
handleCodeChanged(event: SyntheticInputEvent<*>) {
|
||||
this.setState({
|
||||
code: String(event.target.value).trim(),
|
||||
});
|
||||
|
@ -31,31 +45,30 @@ class UserEmailVerify extends React.PureComponent {
|
|||
|
||||
render() {
|
||||
const { cancelButton, errorMessage, email, isPending } = this.props;
|
||||
// <FormField
|
||||
// label={__('Verification Code')}
|
||||
// errorMessage={errorMessage}
|
||||
// render{() => (
|
||||
// <input
|
||||
// name="code"
|
||||
// value={this.state.code}
|
||||
// onChange={event => {
|
||||
// this.handleCodeChanged(event);
|
||||
// }}
|
||||
// />
|
||||
// )}
|
||||
// />
|
||||
|
||||
return (
|
||||
<Form onSubmit={this.handleSubmit.bind(this)}>
|
||||
<Form onSubmit={this.handleSubmit}>
|
||||
<p>Please enter the verification code emailed to {email}.</p>
|
||||
{/* render help separately so it always shows */}
|
||||
<div className="form-field__helper">
|
||||
<FormRow>
|
||||
<FormField
|
||||
stretch
|
||||
name="code"
|
||||
type="text"
|
||||
placeholder="eyJyZWNhcHRjaGEiOiIw..."
|
||||
label={__('Verification Code')}
|
||||
error={errorMessage}
|
||||
value={this.state.code}
|
||||
onChange={event => this.handleCodeChanged(event)}
|
||||
/>
|
||||
</FormRow>
|
||||
<div className="help">
|
||||
<p>
|
||||
{__('Email')} <Button href="mailto:help@lbry.io" label="help@lbry.io" /> or join our{' '}
|
||||
<Button href="https://chat.lbry.io" label="chat" />{' '}
|
||||
{__('Email')} <Button button="link" href="mailto:help@lbry.io" label="help@lbry.io" />{' '}
|
||||
or join our <Button button="link" href="https://chat.lbry.io" label="chat" />{' '}
|
||||
{__('if you encounter any trouble with your code.')}
|
||||
</p>
|
||||
</div>
|
||||
<div className="form-row-submit">
|
||||
<div className="card__actions">
|
||||
<Submit label={__('Verify')} disabled={isPending} />
|
||||
{cancelButton}
|
||||
</div>
|
||||
|
@ -65,4 +78,3 @@ class UserEmailVerify extends React.PureComponent {
|
|||
}
|
||||
|
||||
export default UserEmailVerify;
|
||||
/* eslint-enable */
|
||||
|
|
|
@ -23,8 +23,8 @@ class ModalRemoveFile extends React.PureComponent<Props, State> {
|
|||
super(props);
|
||||
|
||||
this.state = {
|
||||
deleteChecked: true,
|
||||
abandonClaimChecked: false,
|
||||
deleteChecked: false,
|
||||
abandonClaimChecked: true,
|
||||
};
|
||||
|
||||
(this: any).handleDeleteCheckboxClicked = this.handleDeleteCheckboxClicked.bind(this);
|
||||
|
|
|
@ -34,7 +34,12 @@ export const doPrepareEdit = (claim: any) => (dispatch: Dispatch) => {
|
|||
const {
|
||||
author,
|
||||
description,
|
||||
fee,
|
||||
// use same values as default state
|
||||
// fee will be undefined for free content
|
||||
fee = {
|
||||
amount: 0,
|
||||
currency: 'LBC',
|
||||
},
|
||||
language,
|
||||
license,
|
||||
licenseUrl,
|
||||
|
@ -67,7 +72,7 @@ export const doPublish = (params: PublishParams): ThunkAction => {
|
|||
const {
|
||||
name,
|
||||
bid,
|
||||
filePath: file_path,
|
||||
filePath,
|
||||
description,
|
||||
language,
|
||||
license,
|
||||
|
@ -102,7 +107,7 @@ export const doPublish = (params: PublishParams): ThunkAction => {
|
|||
}
|
||||
|
||||
const publishPayload = {
|
||||
file_path,
|
||||
file_path: filePath,
|
||||
name,
|
||||
channel_name: channelName,
|
||||
bid,
|
||||
|
@ -130,52 +135,50 @@ export const doPublish = (params: PublishParams): ThunkAction => {
|
|||
};
|
||||
|
||||
// Calls claim_list_mine until any pending publishes are confirmed
|
||||
export const doCheckPendingPublishes = () => {
|
||||
return (dispatch: Dispatch, getState: GetState) => {
|
||||
const state = getState();
|
||||
const pendingPublishes = selectPendingPublishes(state);
|
||||
const myClaims = selectMyClaimsWithoutChannels(state);
|
||||
export const doCheckPendingPublishes = () => (dispatch: Dispatch, getState: GetState) => {
|
||||
const state = getState();
|
||||
const pendingPublishes = selectPendingPublishes(state);
|
||||
const myClaims = selectMyClaimsWithoutChannels(state);
|
||||
|
||||
let publishCheckInterval;
|
||||
let publishCheckInterval;
|
||||
|
||||
const checkFileList = () => {
|
||||
Lbry.claim_list_mine().then(claims => {
|
||||
const claimsWithoutChannels = claims.filter(claim => !claim.name.match(/^@/));
|
||||
if (myClaims.length !== claimsWithoutChannels.length) {
|
||||
const pendingPublishMap = {};
|
||||
pendingPublishes.forEach(({ name }) => {
|
||||
pendingPublishMap[name] = name;
|
||||
});
|
||||
const checkFileList = () => {
|
||||
Lbry.claim_list_mine().then(claims => {
|
||||
const claimsWithoutChannels = claims.filter(claim => !claim.name.match(/^@/));
|
||||
if (myClaims.length !== claimsWithoutChannels.length) {
|
||||
const pendingPublishMap = {};
|
||||
pendingPublishes.forEach(({ name }) => {
|
||||
pendingPublishMap[name] = name;
|
||||
});
|
||||
|
||||
claims.forEach(claim => {
|
||||
if (pendingPublishMap[claim.name]) {
|
||||
dispatch({
|
||||
type: ACTIONS.REMOVE_PENDING_PUBLISH,
|
||||
data: {
|
||||
name: claim.name,
|
||||
},
|
||||
});
|
||||
dispatch({
|
||||
type: ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED,
|
||||
data: {
|
||||
claims,
|
||||
},
|
||||
});
|
||||
claims.forEach(claim => {
|
||||
if (pendingPublishMap[claim.name]) {
|
||||
dispatch({
|
||||
type: ACTIONS.REMOVE_PENDING_PUBLISH,
|
||||
data: {
|
||||
name: claim.name,
|
||||
},
|
||||
});
|
||||
dispatch({
|
||||
type: ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED,
|
||||
data: {
|
||||
claims,
|
||||
},
|
||||
});
|
||||
|
||||
delete pendingPublishMap[claim.name];
|
||||
}
|
||||
});
|
||||
delete pendingPublishMap[claim.name];
|
||||
}
|
||||
});
|
||||
|
||||
clearInterval(publishCheckInterval);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (pendingPublishes.length) {
|
||||
checkFileList();
|
||||
publishCheckInterval = setInterval(() => {
|
||||
checkFileList();
|
||||
}, 10000);
|
||||
}
|
||||
clearInterval(publishCheckInterval);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (pendingPublishes.length) {
|
||||
checkFileList();
|
||||
publishCheckInterval = setInterval(() => {
|
||||
checkFileList();
|
||||
}, 10000);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -2,6 +2,7 @@ import {
|
|||
selectClaimsByUri,
|
||||
selectIsFetchingClaimListMine,
|
||||
selectMyClaims,
|
||||
selectClaimsById,
|
||||
} from 'redux/selectors/claims';
|
||||
import { createSelector } from 'reselect';
|
||||
import { buildURI } from 'lbryURI';
|
||||
|
@ -106,7 +107,7 @@ export const selectTotalDownloadProgress = createSelector(selectDownloadingFileI
|
|||
});
|
||||
|
||||
export const selectSearchDownloadUris = query =>
|
||||
createSelector(selectFileInfosDownloaded, fileInfos => {
|
||||
createSelector(selectFileInfosDownloaded, selectClaimsById, (fileInfos, claimsById) => {
|
||||
if (!query || !fileInfos.length) {
|
||||
return null;
|
||||
}
|
||||
|
@ -129,19 +130,19 @@ export const selectSearchDownloadUris = query =>
|
|||
|
||||
const downloadResultsFromQuery = [];
|
||||
fileInfos.forEach(fileInfo => {
|
||||
const { channel_name, claim_name, metadata } = fileInfo;
|
||||
const { channel_name: channelName, claim_name: claimName, metadata } = fileInfo;
|
||||
const { author, description, title } = metadata;
|
||||
|
||||
if (channel_name) {
|
||||
const channelName = channel_name.toLowerCase();
|
||||
const strippedOutChannelName = channelName.slice(1); // trim off the @
|
||||
if (searchQueryDictionary[channel_name] || searchQueryDictionary[strippedOutChannelName]) {
|
||||
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 = claim_name.toLowerCase().split('-');
|
||||
const nameParts = claimName.toLowerCase().split('-');
|
||||
if (arrayContainsQueryPart(nameParts)) {
|
||||
downloadResultsFromQuery.push(fileInfo);
|
||||
return;
|
||||
|
@ -171,23 +172,24 @@ export const selectSearchDownloadUris = query =>
|
|||
|
||||
return downloadResultsFromQuery.length
|
||||
? downloadResultsFromQuery.map(fileInfo => {
|
||||
const {
|
||||
channel_name: channelName,
|
||||
claim_id: claimId,
|
||||
claim_name: claimName,
|
||||
value,
|
||||
metadata,
|
||||
} = fileInfo;
|
||||
const { channel_name: channelName, claim_id: claimId, claim_name: claimName } = fileInfo;
|
||||
|
||||
const uriParams = {};
|
||||
|
||||
if (channelName) {
|
||||
const claim = claimsById[claimId];
|
||||
if (claim.value) {
|
||||
uriParams.claimId = claim.value.publisherSignature.certificateId;
|
||||
} else {
|
||||
uriParams.claimId = claimId;
|
||||
}
|
||||
uriParams.channelName = channelName;
|
||||
uriParams.contentName = claimName;
|
||||
} else {
|
||||
uriParams.claimId = claimId;
|
||||
uriParams.claimName = claimName;
|
||||
}
|
||||
|
||||
uriParams.claimId = claimId;
|
||||
uriParams.claimId = claimId;
|
||||
uriParams.contentName = claimName;
|
||||
|
||||
const uri = buildURI(uriParams);
|
||||
return uri;
|
||||
})
|
||||
|
|
|
@ -189,5 +189,5 @@ button:disabled {
|
|||
opacity: 0.8;
|
||||
border-radius: var(--btn-radius);
|
||||
height: var(--btn-height);
|
||||
padding: 0 3px;
|
||||
padding: 10px;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue