rename action member and arguments

This commit is contained in:
Luc 2021-11-01 12:07:05 +01:00
parent 8f0442876c
commit 0cdd5d2c79

View File

@ -10,7 +10,11 @@ class FileBrowserMenu extends Component {
super() super()
this.state = { this.state = {
files: [ files: [
[{}], [{
// Name: "heyhey.mp4",
// Size: 400000000,
// isDir: false
}],
[{}] [{}]
], ],
currentPath: ["", ""], currentPath: ["", ""],
@ -42,7 +46,7 @@ class FileBrowserMenu extends Component {
*/ */
getFiles = (brIndex, newPath) => { getFiles = (brIndex, newPath) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
assert(brIndex !== 0 && brIndex !== 1, {brIndex}) assert(brIndex === 0 || brIndex === 1, {brIndex})
if (newPath === "") newPath = "/" if (newPath === "") newPath = "/"
@ -73,17 +77,20 @@ class FileBrowserMenu extends Component {
/** /**
* *
* @param {Number} brIndex identify which browser wants to do the action * @param {Number} brIndex identify which browser wants to do the action
* @param {String} action type of action to be performed
* @param {String} path dir or file * @param {String} path dir or file
* @param {String} name name of the action to be performed
*/ */
action = (brIndex, path, name) => { doAction = (brIndex, action, path) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
switch(name) { switch(action) {
case "copy": case "copy":
console.log("did copy", path)
break; break;
case "move": case "move":
console.log("did move", path)
break; break;
case "delete": case "delete":
console.log("did delete", path)
break; break;
default: return reject(new Error("Invalid file action")) default: return reject(new Error("Invalid file action"))
} }
@ -122,7 +129,7 @@ class FileBrowserMenu extends Component {
</FileBrowserRemotes> </FileBrowserRemotes>
<FileBrowser <FileBrowser
action={(path, name) => this.action(0, path, name)} action={(a, p) => this.doAction(0, a, p)}
files={files[0]} files={files[0]}
updateFiles={path => this.getFiles(0, path)} updateFiles={path => this.getFiles(0, path)}
currentPath={currentPath[0]} currentPath={currentPath[0]}