From 4d6ad7108679ab774887fbdda1eb62b2791dd555 Mon Sep 17 00:00:00 2001
From: Erick Hitter <services@ethitter.com>
Date: Fri, 16 Dec 2016 20:36:24 -0800
Subject: [PATCH] Only ignore queued clicks if they are more than two seconds
 old, so allow for reconnection delay

---
 index.js | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/index.js b/index.js
index 5f21fd4..a522baa 100644
--- a/index.js
+++ b/index.js
@@ -43,9 +43,15 @@ function listenToButton( bdAddr ) {
     client.addConnectionChannel( cc );
 
     cc.on( 'buttonUpOrDown', function( clickType, wasQueued, timeDiff ) {
-        if ( 'ButtonDown' === clickType && false === wasQueued ) {
-            buttonActivated( bdAddr );
+        if ( 'ButtonDown' !== clickType ) {
+            return;
         }
+
+        if ( wasQueued && timeDiff > 2 ) {
+            return;
+        }
+
+        buttonActivated( bdAddr );
     } );
 }
 
-- 
GitLab