Skip to content

Commit f577f14

Browse files
author
Agent
committed
fix: block multiple file pickers when holding Ctrl+Meta+L
Adds a 1-second throttle trap to readLogFromFile() to prevent multiple file pickers from opening when the hotkey is held down. Fixes #2363
1 parent 7ca71b9 commit f577f14

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/script.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,11 +390,19 @@ function getReg() {
390390
return reg;
391391
}
392392

393-
/**
394-
* read log from file
395-
* @returns {Promise<string>}
396-
*/
393+
// Trap to block consecutive file picker calls within one second (prevents multiple pickers when holding Ctrl+Meta+L)
394+
let filePickerBlocked = false;
395+
397396
function readLogFromFile() {
397+
// Set a trap to block consecutive calls within one second
398+
if (filePickerBlocked) {
399+
return;
400+
}
401+
filePickerBlocked = true;
402+
setTimeout(() => {
403+
filePickerBlocked = false;
404+
}, 1000);
405+
398406
// TODO: This would probably be better off in ./src/utility/gamelog.ts
399407
return new Promise((resolve, reject) => {
400408
const fileInput = document.createElement('input') as HTMLInputElement;

0 commit comments

Comments
 (0)