Merge pull request #2543 from zxawry/thumbnail-slider

reselect file for publish edits
This commit is contained in:
Sean Yesmunt 2019-06-12 11:44:32 -04:00 committed by GitHub
commit 88c6d36857
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 13 deletions

View file

@ -394,15 +394,16 @@ class PublishForm extends React.PureComponent<Props> {
<header className="card__header"> <header className="card__header">
<h2 className="card__title">{__('Thumbnail')}</h2> <h2 className="card__title">{__('Thumbnail')}</h2>
<p className="card__subtitle"> <p className="card__subtitle">
{uploadThumbnailStatus === THUMBNAIL_STATUSES.API_DOWN ? ( {(uploadThumbnailStatus === undefined && __('You should reselect your file to choose a thumbnail')) ||
__('Enter a URL for your thumbnail.') (uploadThumbnailStatus === THUMBNAIL_STATUSES.API_DOWN ? (
) : ( __('Enter a URL for your thumbnail.')
<React.Fragment> ) : (
{__('Upload your thumbnail (.png/.jpg/.jpeg/.gif) to')}{' '} <React.Fragment>
<Button button="link" label={__('spee.ch')} href="https://spee.ch/about" />.{' '} {__('Upload your thumbnail (.png/.jpg/.jpeg/.gif) to')}{' '}
{__('Recommended size: 800x450 (16:9)')} <Button button="link" label={__('spee.ch')} href="https://spee.ch/about" />.{' '}
</React.Fragment> {__('Recommended size: 800x450 (16:9)')}
)} </React.Fragment>
))}
</p> </p>
</header> </header>

View file

@ -49,7 +49,7 @@ const perform = dispatch => ({
fetchFileInfo: uri => dispatch(doFetchFileInfo(uri)), fetchFileInfo: uri => dispatch(doFetchFileInfo(uri)),
fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)), fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)),
openModal: (modal, props) => dispatch(doOpenModal(modal, props)), openModal: (modal, props) => dispatch(doOpenModal(modal, props)),
prepareEdit: (publishData, uri) => dispatch(doPrepareEdit(publishData, uri)), prepareEdit: (publishData, uri, fileInfo) => dispatch(doPrepareEdit(publishData, uri, fileInfo)),
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)), setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
setViewed: uri => dispatch(doSetContentHistoryItem(uri)), setViewed: uri => dispatch(doSetContentHistoryItem(uri)),
markSubscriptionRead: (channel, uri) => dispatch(doRemoveUnreadSubscription(channel, uri)), markSubscriptionRead: (channel, uri) => dispatch(doRemoveUnreadSubscription(channel, uri)),

View file

@ -36,7 +36,7 @@ type Props = {
isSubscribed: boolean, isSubscribed: boolean,
channelUri: string, channelUri: string,
viewCount: number, viewCount: number,
prepareEdit: ({}, string) => void, prepareEdit: ({}, string, {}) => void,
openModal: (id: string, { uri: string }) => void, openModal: (id: string, { uri: string }) => void,
markSubscriptionRead: (string, string) => void, markSubscriptionRead: (string, string) => void,
fetchViewCount: string => void, fetchViewCount: string => void,
@ -268,7 +268,7 @@ class FilePage extends React.Component<Props> {
label={__('Edit')} label={__('Edit')}
navigate="/$/publish" navigate="/$/publish"
onClick={() => { onClick={() => {
prepareEdit(claim, editUri); prepareEdit(claim, editUri, fileInfo);
}} }}
/> />
)} )}

View file

@ -137,7 +137,7 @@ export const doUploadThumbnail = (filePath: string, thumbnailBuffer: Uint8Array)
.catch(err => uploadError(err.message)); .catch(err => uploadError(err.message));
}; };
export const doPrepareEdit = (claim: StreamClaim, uri: string) => (dispatch: Dispatch) => { export const doPrepareEdit = (claim: StreamClaim, uri: string, fileInfo: FileListItem) => (dispatch: Dispatch) => {
const { name, amount, channel_name: channelName, value } = claim; const { name, amount, channel_name: channelName, value } = claim;
const { const {
@ -189,6 +189,15 @@ export const doPrepareEdit = (claim: StreamClaim, uri: string) => (dispatch: Dis
publishData.licenseType = license; publishData.licenseType = license;
} }
if (fileInfo && fileInfo.download_path) {
try {
fs.accessSync(fileInfo.download_path, fs.constants.R_OK);
publishData.filePath = fileInfo.download_path;
} catch (e) {
console.error(e.name, e.message);
}
}
dispatch({ type: ACTIONS.DO_PREPARE_EDIT, data: publishData }); dispatch({ type: ACTIONS.DO_PREPARE_EDIT, data: publishData });
}; };