auto select file on edit
This commit is contained in:
parent
b61f4bfe1f
commit
0c0c634872
3 changed files with 13 additions and 4 deletions
|
@ -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)),
|
||||
|
|
|
@ -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);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
|
|
@ -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 });
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue