Skip to content

Commit dc73f45

Browse files
committed
fix: Improve double-click handling logic for image downloads
1 parent 037c6a5 commit dc73f45

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

manifest.chrome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 3,
33
"name": "Pixely Sort & Save",
4-
"version": "1.2.1",
4+
"version": "1.2.2",
55
"description": "Salva imagens rapidamente em subpastas com nome aleatório.",
66
"permissions": [
77
"downloads",

manifest.firefox.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 2,
33
"name": "Pixely Sort & Save",
4-
"version": "1.2.1",
4+
"version": "1.2.2",
55
"description": "Salva imagens rapidamente em subpastas com nome aleatório.",
66
"permissions": [
77
"downloads",

scripts/content_script.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ function sendContextMenuPosition(x, y) {
112112
// ============================================================================
113113
// DOUBLE CLICK HANDLING
114114
// ============================================================================
115-
async function handleImageDoubleClick(imageUrl) {
115+
async function handleImageDoubleClickValidation() {
116116
const isEnabled = await isDoubleClickEnabled();
117117

118118
if (isEnabled) {
119-
sendDownloadMessage(imageUrl);
119+
return isEnabled;
120120
} else {
121121
let notificationCount = parseInt(
122122
sessionStorage.getItem("doubleClickNotificationCount") || "0"
@@ -136,9 +136,16 @@ async function handleImageDoubleClick(imageUrl) {
136136
}
137137
}
138138

139-
function handleDoubleClickEvent(event) {
139+
async function handleDoubleClickEvent(event) {
140+
const isEnabled = await handleImageDoubleClickValidation();
141+
142+
if (!isEnabled) {
143+
return;
144+
}
145+
140146
if (isImageElement(event.target) || hasValidImageUrl(event.target)) {
141-
return handleImageDoubleClick(event.target.src);
147+
sendDownloadMessage(event.target.src);
148+
return;
142149
}
143150

144151
const imageElement = findImageUnderPointer(event.pageX, event.pageY, 7);
@@ -153,7 +160,7 @@ function handleDoubleClickEvent(event) {
153160
return;
154161
}
155162

156-
handleImageDoubleClick(imageUrl);
163+
sendDownloadMessage(imageUrl);
157164
}
158165

159166
// ============================================================================

0 commit comments

Comments
 (0)