Fixed Table Deletion and Regeneration Bug

This commit is contained in:
Paoda 2019-03-16 20:57:55 -05:00
parent 09a2016ca0
commit 3c452529a9
3 changed files with 44 additions and 11 deletions

View File

@ -1,7 +1,12 @@
{
"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"
}
]
}

View File

@ -21,8 +21,8 @@ export default class Body extends React.Component {
if (err) throw err;
console.log("newTable", obj);
debugger;
self.setState({ table: obj });
});
}
componentWillMount() {

View File

@ -39,15 +39,21 @@ export default class SettingsManager extends Modal {
}
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!");
const template = this.template;
template.id = "-1"; //Impossible ID.
Emitter.emit("newTable", this.template);
Emitter.emit("newTable", template);
}
/**
@ -55,11 +61,33 @@ export default class SettingsManager extends Modal {
* TODO: Make this a function w/ the one inside of Body.js
*/
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!")
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);
saveTable(tableJSON);