🚧 refactor updateFileNmae to thunk, add updatedName param
This commit is contained in:
parent
7d05aa78e3
commit
5df76c249a
2 changed files with 11 additions and 7 deletions
|
@ -135,11 +135,15 @@ export function createFolder(formProps) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateFileName(id, name) {
|
export function updateFileName(id, name, updatedName = '') {
|
||||||
return {
|
return (dispatch) => {
|
||||||
type: ActionTypes.UPDATE_FILE_NAME,
|
// Notify Changes if necessary
|
||||||
id,
|
// Update the Filename
|
||||||
name
|
dispatch({
|
||||||
|
type: ActionTypes.UPDATE_FILE_NAME,
|
||||||
|
id,
|
||||||
|
name
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ export class FileNode extends React.Component {
|
||||||
|
|
||||||
|
|
||||||
handleFileNameChange(event) {
|
handleFileNameChange(event) {
|
||||||
this.props.updateFileName(this.props.id, event.target.value);
|
this.props.updateFileName(this.props.id, event.target.value, this.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
handleKeyPress(event) {
|
handleKeyPress(event) {
|
||||||
|
@ -82,7 +82,7 @@ export class FileNode extends React.Component {
|
||||||
const hasEmptyFilename = newFileName === '';
|
const hasEmptyFilename = newFileName === '';
|
||||||
const hasOnlyExtension = newFileExtension && newFileName === newFileExtension[0];
|
const hasOnlyExtension = newFileExtension && newFileName === newFileExtension[0];
|
||||||
if (hasEmptyFilename || hasNoExtension || notSameExtension || hasOnlyExtension || hasExtensionIfFolder) {
|
if (hasEmptyFilename || hasNoExtension || notSameExtension || hasOnlyExtension || hasExtensionIfFolder) {
|
||||||
this.props.updateFileName(this.props.id, this.originalFileName);
|
this.props.updateFileName(this.props.id, this.originalFileName, this.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue