Make WordPress Core

Changeset 27845


Ignore:
Timestamp:
03/29/2014 09:08:16 AM (11 years ago)
Author:
nacin
Message:

Theme Installer: Avoid race condition during pagination.

props matveb.
see #27055.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/theme.js

    r27843 r27845  
    269269                    self.add( data.themes );
    270270                    self.trigger( 'query:success' );
     271
     272                    // We are done loading themes for now.
     273                    self.loadingThemes = false;
    271274
    272275                }).fail( function() {
     
    332335            }
    333336        });
    334     }
     337    },
     338
     339    // Static status controller for when we are loading themes.
     340    loadingThemes: false
    335341});
    336342
     
    11491155        // Bump `collection.currentQuery.page` and request more themes if we hit the end of the page.
    11501156        this.listenTo( this, 'theme:end', function() {
     1157
     1158            // Make sure we are not already loading
     1159            if ( self.collection.loadingThemes ) {
     1160                return;
     1161            }
     1162
     1163            // Set loadingThemes to true and bump page instance of currentQuery.
     1164            self.collection.loadingThemes = true;
    11511165            self.collection.currentQuery.page++;
     1166
     1167            // Use currentQuery.page to build the themes request.
    11521168            _.extend( self.collection.currentQuery.request, { page: self.collection.currentQuery.page } );
    11531169            self.collection.query( self.collection.currentQuery.request );
Note: See TracChangeset for help on using the changeset viewer.