fixinf delele_current

This commit is contained in:
sanjayk03-dev
2024-04-08 15:35:34 +05:30
parent cfaff540ad
commit 61207ffe8a

View File

@@ -279,7 +279,11 @@ module.exports = {
}, },
delete_current: async function () { delete_current: async function () {
const filename = this.fileName; const filename = this.fileName;
const macro_with_filename = this.state.macros.filter( if (filename == "default") {
this.newGcode = "";
} else {
this.config.macros = [...this.state.macros];
const macro_with_filename = this.config.macros.filter(
item => item.file_name != "default" && item.file_name == this.fileName, item => item.file_name != "default" && item.file_name == this.fileName,
); );
if (macro_with_filename.length != 0) { if (macro_with_filename.length != 0) {
@@ -291,14 +295,11 @@ module.exports = {
item.file_name = "default"; item.file_name = "default";
}); });
} }
if (filename == "default") {
this.newGcode = "";
} else {
api.delete(`file/${filename}`); api.delete(`file/${filename}`);
this.newGcode = ""; this.newGcode = "";
this.config.macros_list = [...this.state.macros_list]; this.config.macros_list = [...this.state.macros_list];
this.config.macros_list = this.config.macros_list.filter(item => item.file_name !== filename); this.config.macros_list = this.config.macros_list.filter(item => item.file_name !== filename);
} this.fileName = "default";
try { try {
await api.put("config/save", this.config); await api.put("config/save", this.config);
this.$dispatch("update"); this.$dispatch("update");
@@ -306,7 +307,7 @@ module.exports = {
console.error("Restore Failed: ", error); console.error("Restore Failed: ", error);
alert("Restore failed"); alert("Restore failed");
} }
this.fileName = "default"; }
this.deleteGCode = false; this.deleteGCode = false;
}, },
clear_macro: async function () { clear_macro: async function () {