]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1430495 - Make loading of Requests dropdown faster
authorKohei Yoshino <kohei.yoshino@gmail.com>
Thu, 18 Jan 2018 05:14:54 +0000 (00:14 -0500)
committerDylan William Hardison <dylan@hardison.net>
Thu, 18 Jan 2018 05:14:54 +0000 (00:14 -0500)
extensions/Review/web/js/badge.js

index ea09ed1169d5f0fd435b8e662d1c41b3256c113e..8580c0ba1cab2be6275de9eb1a7e7b6a44719e1d 100644 (file)
@@ -26,12 +26,14 @@ Bugzilla.Review.Badge = class Badge {
      * @returns {Badge} New Badge instance.
      */
     constructor() {
+        this.initialized = false;
         this.$button = document.querySelector('#header-requests-menu-button');
         this.$panel = document.querySelector('#header-requests .dropdown-panel');
         this.$loading = document.querySelector('#header-requests .dropdown-panel .loading');
 
         if (this.$loading) {
-            this.$button.addEventListener('click', () => this.init(), { once: true });
+            this.$button.addEventListener('mouseover', () => this.init(), { once: true });
+            this.$button.addEventListener('focus', () => this.init(), { once: true });
         }
     }
 
@@ -39,6 +41,12 @@ Bugzilla.Review.Badge = class Badge {
      * Initialize the Reviews dropdown menu.
      */
     async init() {
+        if (this.initialized) {
+            return;
+        }
+
+        this.initialized = true;
+
         const url = this.$panel.querySelector('footer a').href + '&ctype=json';
         const response = await fetch(url, { credentials: 'same-origin' });
         const _requests = response.ok ? await response.json() : [];