reselect file for publish edits #2543

Merged
zxawry merged 2 commits from thumbnail-slider into master 2019-06-12 17:44:33 +02:00
4 changed files with 23 additions and 13 deletions

View file

@ -394,7 +394,8 @@ 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')) ||
(uploadThumbnailStatus === THUMBNAIL_STATUSES.API_DOWN ? (
__('Enter a URL for your thumbnail.') __('Enter a URL for your thumbnail.')
) : ( ) : (
<React.Fragment> <React.Fragment>
@ -402,7 +403,7 @@ class PublishForm extends React.PureComponent<Props> {
<Button button="link" label={__('spee.ch')} href="https://spee.ch/about" />.{' '} <Button button="link" label={__('spee.ch')} href="https://spee.ch/about" />.{' '}
{__('Recommended size: 800x450 (16:9)')} {__('Recommended size: 800x450 (16:9)')}
</React.Fragment> </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 });
}; };