Fixed Table Deletion and Regeneration Bug
This commit is contained in:
parent
09a2016ca0
commit
3c452529a9
|
@ -1,7 +1,12 @@
|
||||||
{
|
{
|
||||||
"folders": [
|
"folders": [
|
||||||
{
|
{
|
||||||
"path": "C:\\Users\\Paoda\\Documents\\programming\\neomelodii"
|
"path": "C:\\Users\\Paoda\\Documents\\programming\\neomelodii",
|
||||||
|
"name": "Source Code"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "C:\\Users\\Paoda\\AppData\\Roaming\\melodii",
|
||||||
|
"name": "Storage"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -21,8 +21,8 @@ export default class Body extends React.Component {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
|
|
||||||
console.log("newTable", obj);
|
console.log("newTable", obj);
|
||||||
debugger;
|
|
||||||
self.setState({ table: obj });
|
self.setState({ table: obj });
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
|
|
|
@ -39,15 +39,21 @@ export default class SettingsManager extends Modal {
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteTable() {
|
deleteTable() {
|
||||||
if (Settings.has("tableJSON")) Settings.delete("tableJSON");
|
// const template = this.template;
|
||||||
|
// template.id = "-1" // Impossible ID
|
||||||
|
|
||||||
|
const template = {
|
||||||
|
thead: {
|
||||||
|
tr: ["Artist", "Title", "Album", "Year", "Genre", "Time"] //contains <th> strings
|
||||||
|
},
|
||||||
|
tbody: []
|
||||||
|
};
|
||||||
|
|
||||||
|
if (Settings.has("tableJSON")) Settings.set("tableJSON", template);
|
||||||
else console.info("There was no Table Saved to Delete!");
|
else console.info("There was no Table Saved to Delete!");
|
||||||
|
|
||||||
const template = this.template;
|
|
||||||
|
|
||||||
template.id = "-1"; //Impossible ID.
|
|
||||||
|
|
||||||
Emitter.emit("newTable", this.template);
|
|
||||||
|
|
||||||
|
Emitter.emit("newTable", template);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,10 +61,32 @@ export default class SettingsManager extends Modal {
|
||||||
* TODO: Make this a function w/ the one inside of Body.js
|
* TODO: Make this a function w/ the one inside of Body.js
|
||||||
*/
|
*/
|
||||||
async regenTable() {
|
async regenTable() {
|
||||||
if (Settings.has("tableJSON")) Settings.delete("tableJSON");
|
|
||||||
|
/*
|
||||||
|
Rather Large Problem w/ regenTable() and deleteTable()
|
||||||
|
I need const template to be a reference to a different object of this.template
|
||||||
|
(Pass by value instead of pass by reference)
|
||||||
|
|
||||||
|
Both deleteTable() and regenTable() modify this.table, which is not the intended behaviour.
|
||||||
|
|
||||||
|
|
||||||
|
Temporary soltuoin will be to define template in each funciton, but I need to figure out how to
|
||||||
|
copy the object instead of reference the object.
|
||||||
|
*/
|
||||||
|
// const template = this.template;
|
||||||
|
// template.id = "-1";
|
||||||
|
|
||||||
|
const template = {
|
||||||
|
thead: {
|
||||||
|
tr: ["Artist", "Title", "Album", "Year", "Genre", "Time"] //contains <th> strings
|
||||||
|
},
|
||||||
|
tbody: []
|
||||||
|
};
|
||||||
|
|
||||||
|
if (Settings.has("tableJSON")) Settings.set("tableJSON", template);
|
||||||
else console.info("There was no Table Saved to Delete!")
|
else console.info("There was no Table Saved to Delete!")
|
||||||
|
|
||||||
const tableJSON = await generate("C:\\Users\\Paoda\\Downloads\\Music", this.template);
|
const tableJSON = await generate("C:\\Users\\Paoda\\Downloads\\Music", template);
|
||||||
|
|
||||||
Emitter.emit("newTable", tableJSON);
|
Emitter.emit("newTable", tableJSON);
|
||||||
|
|
||||||
|
|
Reference in New Issue