From 756178234538ee61346c556f2bdf05a497900351 Mon Sep 17 00:00:00 2001 From: Kohei Yoshino Date: Thu, 18 Jan 2018 00:14:54 -0500 Subject: Bug 1430495 - Make loading of Requests dropdown faster --- extensions/Review/web/js/badge.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'extensions/Review') diff --git a/extensions/Review/web/js/badge.js b/extensions/Review/web/js/badge.js index ea09ed116..8580c0ba1 100644 --- a/extensions/Review/web/js/badge.js +++ b/extensions/Review/web/js/badge.js @@ -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() : []; -- cgit v1.2.3-24-g4f1b