From 0f5e7eeb73b487745de49190785085fd8677d8b7 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Tue, 19 Apr 2022 12:55:23 -0600 Subject: [PATCH] keybinds for delete modal + bugs --- scripts/contextmenu/delete-folder.js | 19 +++++++++++++------ scripts/modal/post.js | 10 ++++++---- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/scripts/contextmenu/delete-folder.js b/scripts/contextmenu/delete-folder.js index e0e2f1f..a9c6165 100644 --- a/scripts/contextmenu/delete-folder.js +++ b/scripts/contextmenu/delete-folder.js @@ -8,7 +8,6 @@ const postModal = require('../modal/post'); const showError = require('../modal/common/error'); const clearModals = require('../modal/clearmodals'); const newToast = require('../toast/createtoast'); -const refresh = require('../fileview/refresh'); module.exports = () => { if (window.kade.modal) {return;} @@ -33,26 +32,34 @@ module.exports = () => { conf.innerHTML = 'Delete it!'; let cxl = document.createElement('button'); cxl.innerHTML = "Nevermind"; - modal.appendChild(cxl); + cxl.onclick = () => { + lightRefresh(); + modalOut.remove(); + postModal(modalOut.id); + }; conf.onclick = () => { try { fs.rmdirSync(path.join(window.kade.cpath, window.kade.currentFolder)); - refresh(window.kade.cpath); + postModal(modalOut.id); + modalOut.remove(); + lightRefresh(window.kade.cpath); newToast("Folder Deleted", "Your folder has been deleted successfully."); } catch { newToast("Folder not Deleted", "An error caused that folder to not be deleted.", "#b24355", false, 5, () => {showError("Folder Deletion", "There was an unknown error while trying to delete that folder. It may be a permissions issue, or the host folder doesn't exist anymore.");}); clearModals(); + try {modalOut.remove();} catch {} + postModal(modalOut.id); } - postModal(modalOut.id); }; cont.appendChild(conf); - let msm = new Mousetrap(modal); + cont.appendChild(cxl); + let msm = new Mousetrap(); msm.bind('esc', () => { lightRefresh(); modalOut.remove(); postModal(modalOut.id); }); - msm.bind('enter', () => {conf.click();}); + msm.bind('enter', () => {conf.click(); console.log('hewwo');}); let close = document.createElement('a'); close.className = 'close-button'; close.onclick = () => { diff --git a/scripts/modal/post.js b/scripts/modal/post.js index e84085a..850c1a9 100755 --- a/scripts/modal/post.js +++ b/scripts/modal/post.js @@ -1,8 +1,10 @@ const transit = require("./transit"); module.exports = (id) => { - document.getElementById('modal-block').remove(); - window.kade.modal = false; - document.body.style.overflowY = 'overlay'; - transit(id, false); + try { + try {document.getElementById('modal-block').remove();} catch {} + window.kade.modal = false; + document.body.style.overflowY = 'overlay'; + transit(id, false); + } catch {} }; \ No newline at end of file