Merge pull request #318 from sanskar-mk2/better-delete

deletion checkbox delegate to parent
This commit is contained in:
Cohee
2023-05-16 10:41:43 +03:00
committed by GitHub

View File

@@ -254,7 +254,7 @@ let dialogueResolve = null;
let chat_metadata = {}; let chat_metadata = {};
let streamingProcessor = null; let streamingProcessor = null;
let crop_data = undefined; let crop_data = undefined;
let is_delete_mode = false;
let fav_ch_checked = false; let fav_ch_checked = false;
//initialize global var for future cropped blobs //initialize global var for future cropped blobs
@@ -4906,14 +4906,19 @@ $(document).ready(function () {
is_use_scroll_holder = false; is_use_scroll_holder = false;
} }
}); });
$(document).on("click", ".del_checkbox", function () {
//when a 'delete message' checkbox is clicked $(document).on("click", ".mes", function () {
$(".del_checkbox").each(function () { //when a 'delete message' parent div is clicked
// and we are in delete mode
if (!is_delete_mode) {
return;
}
$(".mes").children(".del_checkbox").each(function () {
$(this).prop("checked", false); $(this).prop("checked", false);
$(this).parent().css("background", css_mes_bg); $(this).parent().css("background", css_mes_bg);
}); });
$(this).parent().css("background", "#600"); //sets the bg of the mes selected for deletion $(this).css("background", "#600"); //sets the bg of the mes selected for deletion
var i = $(this).parent().attr("mesid"); //checks the message ID in the chat var i = $(this).attr("mesid"); //checks the message ID in the chat
this_del_mes = i; this_del_mes = i;
while (i < chat.length) { while (i < chat.length) {
//as long as the current message ID is less than the total chat length //as long as the current message ID is less than the total chat length
@@ -4925,6 +4930,7 @@ $(document).ready(function () {
//console.log(i); //console.log(i);
} }
}); });
$(document).on("click", "#user_avatar_block .avatar", function () { $(document).on("click", "#user_avatar_block .avatar", function () {
user_avatar = $(this).attr("imgfile"); user_avatar = $(this).attr("imgfile");
reloadUserAvatar(); reloadUserAvatar();
@@ -5622,6 +5628,7 @@ $(document).ready(function () {
} }
}); });
} }
is_delete_mode = true;
} }
}); });
@@ -5640,6 +5647,7 @@ $(document).ready(function () {
this_del_mes = 0; this_del_mes = 0;
console.log('canceled del msgs, calling showswipesbtns'); console.log('canceled del msgs, calling showswipesbtns');
showSwipeButtons(); showSwipeButtons();
is_delete_mode = false;
}); });
//confirms message delation with the "ok" button //confirms message delation with the "ok" button
@@ -5668,6 +5676,7 @@ $(document).ready(function () {
$('#chat .mes').eq(-2).removeClass('last_mes'); $('#chat .mes').eq(-2).removeClass('last_mes');
console.log('confirmed del msgs, calling showswipesbtns'); console.log('confirmed del msgs, calling showswipesbtns');
showSwipeButtons(); showSwipeButtons();
is_delete_mode = false;
}); });
$("#settings_perset").change(function () { $("#settings_perset").change(function () {