Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only applies to continuous mode. The period, in milliseconds, before the same QR code #56

Closed
larrycosta opened this issue Jan 30, 2018 · 1 comment

Comments

@larrycosta
Copy link

larrycosta commented Jan 30, 2018

Well, I do not sleep for several days. I tested several Qr readers and the only one I found interesting was this one, to perform a quick reading, it is necessary to decrease "delay", the same Qr is repeated several times.

The solution I found for not to repeat for a certain time:

bundle.js > add rows the top:

var arrayResult = [];
var timeoutResult;

function removeA(arr) {
    var what, a = arguments, L = a.length, ax;
    while (L > 1 && arr.length) {
        what = a[--L];
        while ((ax= arr.indexOf(what)) !== -1) {
            arr.splice(ax, 1);
        }
    }
    return arr;
}

function timeout(arrayResult, result) {
	timeoutResult = window.setTimeout(function(){ 
		removeA(arrayResult, result);
	}, 5000);
}

function clearResultTimeout() {
    clearTimeout(timeoutResult);
}

function insereValor(result) {
	
	if (arrayResult.indexOf(result) < 0){

		clearResultTimeout(); // delete timeout from (result) previous
		arrayResult.shift(); // remove lock (result) previous
		arrayResult.push(result); // add lock (result) current

		this.setState({ result: result }); // result
		
		timeout(arrayResult, result);  // setTimeout

	}else{
		//alert(result); // lockout timeout
	}
}

bundle.js > search by for lines:

	    value: function handleScan(result) {
			if (result) {
				this.setState({ result: result });
			}
	    }

bundle.js > change to:

	    value: function handleScan(result) {
			if (result) {
				insereValor(result);
			}
	    }

Is the reading happens faster and if the QR is repeated, it is discarded for 5 seconds.

@JodusNodus
Copy link
Owner

Yes the scanner will give the result of every scan. Even if that might be the same as the previous result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants