Adding shortcut to permanently delete files bypassing trash

This commit is contained in:
vineethvk11 2024-03-08 01:50:47 +05:30
parent 440e832237
commit 34c0bd6b7f

View File

@ -1305,11 +1305,39 @@ window.initgui = async function(){
}
})
$(document).bind('keyup', async function(e){
$(document).bind('keydown', async function(e){
const focused_el = document.activeElement;
//-----------------------------------------------------------------------
// Delete (win)/ shift+del (Mac) key pressed
// Shift+Delete (win)/ option+command+delete (Mac) key pressed
// Permanent delete bypassing trash after alert
//-----------------------------------------------------------------------
if((e.keyCode === 46 && e.shiftKey) || (e.altKey && e.metaKey && e.keyCode === 8)) {
let $selected_items = $(active_element).closest(`.item-container`).find(`.item-selected`);
if($selected_items.length > 0){
const alert_resp = await UIAlert({
message: `Are you sure you want to permanently delete these items?`,
buttons:[
{
label: 'Delete',
type: 'primary',
},
{
label: 'Cancel'
},
]
})
if((alert_resp) === 'Delete'){
for (let index = 0; index < $selected_items.length; index++) {
const element = $selected_items[index];
await delete_item(element);
}
}
}
return false;
}
//-----------------------------------------------------------------------
// Delete (win)/ ctrl+delete (Mac) / cmd+delete (Mac) key pressed
// Permanent delete from trash after alert or move to trash
//-----------------------------------------------------------------------
if(e.keyCode === 46 || (e.keyCode === 8 && (e.ctrlKey || e.metaKey))) {
// permanent delete?
@ -1354,6 +1382,7 @@ window.initgui = async function(){
}
}
}
return false;
}
//-----------------------------------------------------------------------