auto select file on edit

This commit is contained in:
zxawry 2019-06-11 16:30:36 +01:00
parent b61f4bfe1f
commit 0c0c634872
No known key found for this signature in database
GPG key ID: 70F5D1B4F51F051A
3 changed files with 13 additions and 4 deletions

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 });
};