fix in delete_current

This commit is contained in:
sanjayk03-dev
2024-03-29 02:22:53 +05:30
parent 584f2c0565
commit 5a725c34d6

View File

@@ -472,16 +472,17 @@ module.exports = {
}, },
create_new_folder: async function () { create_new_folder: async function () {
const folder_name = this.folder_name.trim()
if ( if (
this.folder_name.trim() != "" && folder_name != "" &&
!this.config.gcode_list.find(item => item.type == "folder" && item.name == this.folder_name) !this.config.gcode_list.find(item => item.type == "folder" && item.name == folder_name)
) { ) {
this.config.gcode_list.push({ this.config.gcode_list.push({
name: this.folder_name, name: folder_name,
type: "folder", type: "folder",
files: [], files: [],
}); });
this.state.folder = this.folder_name; this.state.folder = folder_name;
this.edited = false; this.edited = false;
this.create_folder = false; this.create_folder = false;
this.folder_name = ""; this.folder_name = "";
@@ -542,13 +543,16 @@ module.exports = {
delete_current: async function () { delete_current: async function () {
this.config.non_macros_list = this.config.non_macros_list.filter(item => item.file_name != this.state.selected); this.config.non_macros_list = this.config.non_macros_list.filter(item => item.file_name != this.state.selected);
if (this.state.selected && (this.state.folder == "Unorganized files" || !this.state.folder)) { if (this.state.selected && (this.state.folder == "Unorganized files" || !this.state.folder)) {
this.config.gcode_list.filter(item => item.type == "file" && item.name != this.state.selected); this.config.gcode_list = this.config.gcode_list.filter(
item => item.type == "file" && item.name != this.state.selected,
);
} else { } else {
const file_to_delete = this.config.gcode_list.find( const file_to_delete = this.config.gcode_list.find(
item => item.name == this.state.folder && item.type == "folder", item => item.name == this.state.folder && item.type == "folder",
); );
file_to_delete.files.filter(item => item.file_name != this.state.selected); this.config.gcode_list = file_to_delete.files.filter(item => item.file_name != this.state.selected);
} }
if (!this.config.macros_list.find(item => item.file_name == this.state.selected)) { if (!this.config.macros_list.find(item => item.file_name == this.state.selected)) {
api.delete(`file/${this.state.selected}`); api.delete(`file/${this.state.selected}`);