← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~gmb/launchpad/speed-up-subscription-overlay-bug-719249 into lp:launchpad

 

Graham Binns has proposed merging lp:~gmb/launchpad/speed-up-subscription-overlay-bug-719249 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  #719249 The new direct subscription overlay takes too long to load
  https://bugs.launchpad.net/bugs/719249

For more details, see:
https://code.launchpad.net/~gmb/launchpad/speed-up-subscription-overlay-bug-719249/+merge/50148

This branch tweaks the new advanced bug subscription overlay to make it
faster by pre-loading the contents of the overlay when it is initally
created (this is done asynchronously and doesn't affect page render
time).

The overlay is also repopulated after the user makes a change to their
subscription, subscribes or unsubscribes, so that the overlay will
always appear quickly but will also always have the right stuff in it.
-- 
https://code.launchpad.net/~gmb/launchpad/speed-up-subscription-overlay-bug-719249/+merge/50148
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~gmb/launchpad/speed-up-subscription-overlay-bug-719249 into lp:launchpad.
=== modified file 'lib/lp/bugs/javascript/bugtask_index_portlets.js'
--- lib/lp/bugs/javascript/bugtask_index_portlets.js	2011-02-15 18:16:28 +0000
+++ lib/lp/bugs/javascript/bugtask_index_portlets.js	2011-02-17 13:19:03 +0000
@@ -273,6 +273,12 @@
     subscription.set('is_direct', is_direct);
     subscription.set('has_dupes', has_dupes);
 
+    var subscription_overlay;
+    if (namespace.use_advanced_subscriptions) {
+        subscription_overlay = setup_advanced_subscription_overlay(
+            subscription);
+    }
+
     if (subscription.is_node()) {
         subscription.get('link').on('click', function(e) {
             e.halt();
@@ -281,8 +287,6 @@
             subscription.set('is_team', false);
             var parent = e.target.get('parentNode');
             if (namespace.use_advanced_subscriptions) {
-                var subscription_overlay =
-                    setup_advanced_subscription_overlay(subscription);
                 subscription_overlay.show();
             } else {
                 // Look for the false conditions of subscription, which
@@ -491,6 +495,7 @@
  * @param subscription {Object} A Y.lp.bugs.subscriber.Subscription object.
  */
 function setup_advanced_subscription_overlay(subscription) {
+    subscription.enable_spinner();
     var subscription_overlay = new Y.lazr.FormOverlay({
         headerContent: '<h2>Subscribe to bug</h2>',
         form_submit_button:
@@ -500,17 +505,21 @@
         centered: true,
         visible: false
     });
+
+    var subscription_link_url = subscription.get(
+        'link').get('href') + '/++form++';
     subscription_overlay.set(
         'form_submit_callback', function(form_data) {
         handle_advanced_subscription_overlay(subscription, form_data);
         subscription_overlay.hide();
+        subscription_overlay.loadFormContentAndRender(
+            subscription_link_url);
     });
-
-    var subscription_link_url = subscription.get(
-        'link').get('href') + '/++form++';
     subscription_overlay.loadFormContentAndRender(
         subscription_link_url);
     subscription_overlay.render('#privacy-form-container');
+    subscription.disable_spinner();
+
     return subscription_overlay
 }