Avoid dbus timeout by timeout function in js #421.
authorDaniel Carl <danielcarl@gmx.de>
Wed, 21 Jun 2017 20:50:11 +0000 (22:50 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Wed, 21 Jun 2017 20:50:11 +0000 (22:50 +0200)
I don't understand why the JavaScript blocks the dbus processing or the
return from JavaScript on case of e.click() or on window.location.href =
href; the later only cause dbus timeout when the url does not change
except of the location hash.

src/scripts/hints.js

index 0bdc71b..2942a77 100644 (file)
@@ -414,15 +414,17 @@ var hints = Object.freeze((function(){
 
     /* internal used methods */
     function open(e) {
-        var href;
-        if ((href = e.getAttribute('href')) && href != '#') {
-            window.location.href = href;
-        } else {
-            /* We call click() in async mode to return as fast as possible. If
-             * we don't return immediately, the EvalJS dbus call will probably
-             * timeout and cause errors. */
-            window.setTimeout(function() {e.click();}, 0);
-        }
+        /* We call click() in async mode to return as fast as possible. If
+         * we don't return immediately, the EvalJS dbus call will probably
+         * timeout and cause errors. */
+        window.setTimeout(function() {
+            var href;
+            if ((href = e.getAttribute('href')) && href != '#') {
+                window.location.href = href;
+            } else {
+                e.click();
+            }
+        }, 0);
     }
 
     /* set focus on hint with given index valid hints array */