Changeset - dbd2f2891585
[Not reviewed]
default
0 2 0
Mads Kiilerich - 11 years ago 2014-10-03 00:20:36
madski@unity3d.com
pull requests: abort pending ajax requests before starting new one

Quick navigation and different load times could cause an old result to
overwrite a new one.
2 files changed with 16 insertions and 3 deletions:
0 comments (0 inline, 0 general)
kallithea/public/js/base.js
Show inline comments
 
@@ -362,7 +362,7 @@ function asynchtml(url, $target, success
 
    }
 
    $target.html(_TM['Loading ...']).css('opacity','0.3');
 

	
 
    $.ajax({url: url, data: args, headers: {'X-PARTIAL-XHR': '1'}, cache: false, dataType: 'html'})
 
    return $.ajax({url: url, data: args, headers: {'X-PARTIAL-XHR': '1'}, cache: false, dataType: 'html'})
 
        .done(function(html) {
 
                $target.html(html);
 
                $target.css('opacity','1.0');
 
@@ -372,6 +372,8 @@ function asynchtml(url, $target, success
 
                }
 
            })
 
        .fail(function(jqXHR, textStatus, errorThrown) {
 
                if (textStatus == "abort")
 
                    return;
 
                console.log('Ajax failure: ' + textStatus);
 
                $target.html('<span class="error_red">ERROR: {0}</span>'.format(textStatus));
 
                $target.css('opacity','1.0');
kallithea/templates/pullrequests/pullrequest.html
Show inline comments
 
@@ -146,10 +146,16 @@ ${self.repo_context_bar('showpullrequest
 

	
 
  pyroutes.register('pullrequest_repo_info', "${url('pullrequest_repo_info',repo_name='%(repo_name)s')}", ['repo_name']);
 

	
 
  var pendingajax = undefined;
 
  var otherrepoChanged = function(){
 
      var repo_name = $('#other_repo').val();
 
      ajaxGET(pyroutes.url('pullrequest_repo_info', {"repo_name": repo_name}),
 
      if (pendingajax) {
 
          pendingajax.abort();
 
          pendingajax = undefined;
 
      }
 
      pendingajax = ajaxGET(pyroutes.url('pullrequest_repo_info', {"repo_name": repo_name}),
 
          function(o){
 
              pendingajax = undefined;
 
              var data = JSON.parse(o.responseText);
 
              $('#other_repo_desc').html(data.description);
 

	
 
@@ -217,7 +223,12 @@ ${self.repo_context_bar('showpullrequest
 
          url = url.replace(k,rev_data[k]);
 
      }
 

	
 
      asynchtml(url, $('#pull_request_overview'), function(o){
 
      if (pendingajax) {
 
          pendingajax.abort();
 
          pendingajax = undefined;
 
      }
 
      pendingajax = asynchtml(url, $('#pull_request_overview'), function(o){
 
          pendingajax = undefined;
 
          var jsdata = eval('('+YUD.get('jsdata').innerHTML+')'); // TODO: just get json
 
          var r = new BranchRenderer('graph_canvas', 'graph_content_pr');
 
          r.render(jsdata,100);
0 comments (0 inline, 0 general)