From 8c7981b8d0f775ff264f5671882af17df99cab6b Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Fri, 3 May 2019 19:19:24 -0400 Subject: [PATCH] delete files changes selector, delete current file reloads --- src/ui.ts | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/ui.ts b/src/ui.ts index b2609763..37562461 100644 --- a/src/ui.ts +++ b/src/ui.ts @@ -101,6 +101,13 @@ function setLastPreset(id:string) { } } +function unsetLastPreset() { + if (hasLocalStorage) { + delete qs['file']; + localStorage.removeItem("__lastid_"+platform_id); + } +} + function initProject() { current_project = new CodeProject(newWorker(), platform_id, platform, store); projectWindows = new ProjectWindows($("#workspace")[0] as HTMLElement, current_project); @@ -337,8 +344,9 @@ function handleFileUpload(files: File[]) { alert("Error uploading " + path + ": " + err); else { console.log("Uploaded " + path + " " + data.length + " bytes"); - if (index == 1) + if (index == 1) { qs['file'] = path; // TODO? + } uploadNextFile(); } }); @@ -494,10 +502,14 @@ function _deleteFile(e) { if (fn.startsWith("local/")) { if (confirm("Delete '" + fn + "'?")) { store.removeItem(fn, () => { - alert("Deleted " + fn); - updateSelector(); - // TODO: rebuild? - //gotoNewLocation(); + // if we delete what is selected + if (qs['file'] == fn) { + unsetLastPreset(); + gotoNewLocation(); + } else { + updateSelector(); + alert("Deleted " + fn); + } }); } } else {