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,7 +394,8 @@ class PublishForm extends React.PureComponent<Props> {
<header className="card__header">
<h2 className="card__title">{__('Thumbnail')}</h2>
<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.')
) : (
<React.Fragment>
@ -402,7 +403,7 @@ class PublishForm extends React.PureComponent<Props> {
<Button button="link" label={__('spee.ch')} href="https://spee.ch/about" />.{' '}
{__('Recommended size: 800x450 (16:9)')}
</React.Fragment>
)}
))}
</p>
</header>

View file

@ -49,7 +49,7 @@ const perform = dispatch => ({
fetchFileInfo: uri => dispatch(doFetchFileInfo(uri)),
fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)),
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)),
setViewed: uri => dispatch(doSetContentHistoryItem(uri)),
markSubscriptionRead: (channel, uri) => dispatch(doRemoveUnreadSubscription(channel, uri)),

View file

@ -36,7 +36,7 @@ type Props = {
isSubscribed: boolean,
channelUri: string,
viewCount: number,
prepareEdit: ({}, string) => void,
prepareEdit: ({}, string, {}) => void,
openModal: (id: string, { uri: string }) => void,
markSubscriptionRead: (string, string) => void,
fetchViewCount: string => void,
@ -268,7 +268,7 @@ class FilePage extends React.Component<Props> {
label={__('Edit')}
navigate="/$/publish"
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));
};
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 {
@ -189,6 +189,15 @@ export const doPrepareEdit = (claim: StreamClaim, uri: string) => (dispatch: Dis
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 });
};