Skip to content

Commit

Permalink
Fix timeout logic and build
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed Feb 3, 2021
1 parent dde68fc commit 71d31db
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"scripts": {
"build": "parcel build source/manifest.json --dist-dir distribution --no-cache --detailed-report 0",
"build": "parcel build source/manifest.json --no-source-maps --no-optimize --dist-dir distribution --no-cache --detailed-report 0",
"lint": "xo",
"test": "xo && npm run build",
"watch": "parcel watch source/manifest.json --dist-dir distribution --no-cache --no-hmr"
Expand Down
7 changes: 5 additions & 2 deletions source/ghost-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const activeFields = new Set();

let isWaitingForActivation = false;
const startTimeout = 15000;
let timeoutHandle;

class ContentEditableWrapper {
constructor(element) {
Expand Down Expand Up @@ -202,6 +203,7 @@ class GhostTextField {

tryFocus() {
if (isWaitingForActivation && this.state === 'inactive') {
clearTimeout(timeoutHandle);
this.activate();
isWaitingForActivation = false;
document.body.classList.remove('GT--waiting');
Expand Down Expand Up @@ -258,7 +260,7 @@ function notify(type, message, timeout = getMessageDisplayTime(message)) {
}

function startGT() {
clearTimeout(stopGT);
clearTimeout(timeoutHandle);

registerElements();
console.info(knownElements.size + ' fields on the page');
Expand Down Expand Up @@ -295,7 +297,8 @@ function startGT() {
notify('log', 'Click on the desired element to activate it or right-click the GhostText icon to stop the connection.', startTimeout);
}

setTimeout(stopGT, startTimeout);
clearTimeout(timeoutHandle);
timeoutHandle = setTimeout(stopGT, startTimeout);
}

function stopGT() {
Expand Down
2 changes: 1 addition & 1 deletion source/humane-ghosttext.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
z-index: 2147483647;
font-family: sans-serif;
font-size: 16px;
top: 0;
top: 10px;
right: 10px;
width: 330px;
max-width: 90%;
Expand Down

0 comments on commit 71d31db

Please sign in to comment.