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

Proposed by Graham Binns
Status: Merged
Merged at revision: 12411
Proposed branch: lp:~gmb/launchpad/speed-up-subscription-overlay-bug-719249
Merge into: lp:launchpad
Diff against target: 80 lines (+35/-7)
1 file modified
lib/lp/bugs/javascript/bugtask_index_portlets.js (+35/-7)
To merge this branch: bzr merge lp:~gmb/launchpad/speed-up-subscription-overlay-bug-719249
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+50148@code.launchpad.net

Commit message

[r=allenap][bug=719249] The advanced bug subscription overlay is now pre-populated in order to speed it up a bit.

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) wrote :

Nice improvement.

[1]

+ subscription.enable_spinner();
...
+ subscription.disable_spinner();

This pair runs in the same function; the spinner is not disabled after
some asynchronous activity via a callback or event. I doubt that the
spinner will appear for anything more than a fraction of a second,
possibly not at all.

[2]

+ subscription.disable_spinner();
+
     return subscription_overlay

Not your change, but there's no semi-colon here.

review: Approve
Revision history for this message
Graham Binns (gmb) wrote :

> [1]
>
> +    subscription.enable_spinner();
> ...
> +    subscription.disable_spinner();
>
> This pair runs in the same function; the spinner is not disabled after
> some asynchronous activity via a callback or event. I doubt that the
> spinner will appear for anything more than a fraction of a second,
> possibly not at all.

This is a compromise to take care of Rob and Gary's concerns about
this change increasing the time it takes for the JS setup on
BugTask:+index to complete. It will make more of a difference on
production where loading the ++form++ for +subscribe is a bit on the
slow side (that's where I found this bug).

> [2]
>
> +    subscription.disable_spinner();
> +
>     return subscription_overlay
>
> Not your change, but there's no semi-colon here.

Good catch (it was my change, just not in this branch).

Revision history for this message
Gavin Panella (allenap) wrote :

> This is a compromise to take care of Rob and Gary's concerns about
> this change increasing the time it takes for the JS setup on
> BugTask:+index to complete. It will make more of a difference on
> production where loading the ++form++ for +subscribe is a bit on the
> slow side (that's where I found this bug).

My point is that that the spinner won't be seen because this function
will complete very quickly, so it's superfluous and doesn't do what
you expect it to.

Of course, I might be misunderstanding it :)

Revision history for this message
Graham Binns (gmb) wrote :

On 17 February 2011 14:14, Gavin Panella <email address hidden> wrote:
> My point is that that the spinner won't be seen because this function
> will complete very quickly, so it's superfluous and doesn't do what
> you expect it to.

OIC, right. We need to wait for the async stuff to return. Oops. I'll fix that.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/javascript/bugtask_index_portlets.js'
2--- lib/lp/bugs/javascript/bugtask_index_portlets.js 2011-02-15 18:16:28 +0000
3+++ lib/lp/bugs/javascript/bugtask_index_portlets.js 2011-02-18 09:00:00 +0000
4@@ -273,6 +273,12 @@
5 subscription.set('is_direct', is_direct);
6 subscription.set('has_dupes', has_dupes);
7
8+ var subscription_overlay;
9+ if (namespace.use_advanced_subscriptions) {
10+ subscription_overlay = setup_advanced_subscription_overlay(
11+ subscription);
12+ }
13+
14 if (subscription.is_node()) {
15 subscription.get('link').on('click', function(e) {
16 e.halt();
17@@ -281,8 +287,6 @@
18 subscription.set('is_team', false);
19 var parent = e.target.get('parentNode');
20 if (namespace.use_advanced_subscriptions) {
21- var subscription_overlay =
22- setup_advanced_subscription_overlay(subscription);
23 subscription_overlay.show();
24 } else {
25 // Look for the false conditions of subscription, which
26@@ -491,6 +495,7 @@
27 * @param subscription {Object} A Y.lp.bugs.subscriber.Subscription object.
28 */
29 function setup_advanced_subscription_overlay(subscription) {
30+ subscription.enable_spinner("Loading...");
31 var subscription_overlay = new Y.lazr.FormOverlay({
32 headerContent: '<h2>Subscribe to bug</h2>',
33 form_submit_button:
34@@ -500,18 +505,41 @@
35 centered: true,
36 visible: false
37 });
38+
39+ var subscription_link_url = subscription.get(
40+ 'link').get('href') + '/++form++';
41 subscription_overlay.set(
42 'form_submit_callback', function(form_data) {
43 handle_advanced_subscription_overlay(subscription, form_data);
44 subscription_overlay.hide();
45+ subscription_overlay.loadFormContentAndRender(
46+ subscription_link_url);
47 });
48
49- var subscription_link_url = subscription.get(
50- 'link').get('href') + '/++form++';
51- subscription_overlay.loadFormContentAndRender(
52- subscription_link_url);
53+ // Normally we'd just call loadFormContentAndRender() here, but we
54+ // want to be able to have our own callback for when loading the
55+ // content is complete.
56+ function on_success(id, response) {
57+ subscription_overlay.set(
58+ 'form_content', response.responseText);
59+ subscription_overlay.renderUI();
60+ subscription_overlay.bindUI();
61+ subscription.disable_spinner();
62+ }
63+ function on_failure(id, response, subscription_overlay) {
64+ subscription_overlay.set(
65+ 'form_content',
66+ "Sorry, an error occurred while loading the form.");
67+ subscription_overlay.renderUI();
68+ subscription.disable_spinner();
69+ }
70+ var config = {
71+ on: {success: on_success, failure: on_failure},
72+ }
73+ Y.io(subscription_link_url, config);
74 subscription_overlay.render('#privacy-form-container');
75- return subscription_overlay
76+
77+ return subscription_overlay;
78 }
79
80 /*