Skip to content
This repository was archived by the owner on Jan 27, 2025. It is now read-only.

Commit 8550b8f

Browse files
clean up
1 parent e4262d0 commit 8550b8f

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

demo-site/nested-editable.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,34 +54,28 @@ class NestedEditableDemo extends React.Component {
5454
})
5555
}
5656
handleCreateFiles = (files, prefix) => {
57-
this.setState(state => {
57+
this.setState(prevState => {
5858
const newFiles = files.map((file) => {
5959
let newKey = prefix
6060
if (prefix !== '' && prefix.substring(prefix.length - 1, prefix.length) !== '/') {
6161
newKey += '/'
6262
}
63+
const invalidChar = ['/', '\\']
64+
if (invalidChar.some(char => file.name.indexOf(char) !== -1)) return
6365
newKey += file.name
6466
return {
6567
key: newKey,
6668
size: file.size,
6769
modified: +Moment(),
6870
}
6971
})
70-
7172
const uniqueNewFiles = []
72-
newFiles.map((newFile) => {
73-
let exists = false
74-
state.files.map((existingFile) => {
75-
if (existingFile.key === newFile.key) {
76-
exists = true
77-
}
78-
})
79-
if (!exists) {
80-
uniqueNewFiles.push(newFile)
81-
}
73+
newFiles.forEach((newFile) => {
74+
const exists = prevState.files.some(existingFile => (existingFile.key === newFile.key))
75+
if (!exists) uniqueNewFiles.push(newFile)
8276
})
83-
state.files = state.files.concat(uniqueNewFiles)
84-
return state
77+
const updatedFiles = [...prevState.files, uniqueNewFiles]
78+
return { files: updatedFiles }
8579
})
8680
}
8781
handleRenameFolder = (oldKey, newKey) => {

src/base-file.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ class BaseFile extends React.Component {
6565

6666
handleFileClick = (event) => {
6767
event && event.preventDefault()
68-
6968
this.props.browserProps.preview({
7069
url: this.props.url,
7170
name: this.getName(),

src/base-folder.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class BaseFolder extends React.Component {
8080
}
8181
handleNewNameChange = (event) => {
8282
const newName = this.newNameRef.value
83-
this.setState({newName: newName})
83+
this.setState({ newName: newName })
8484
}
8585
handleRenameSubmit = (event) => {
8686
event.preventDefault()

0 commit comments

Comments
 (0)