Skip to content

Commit

Permalink
Prevent unnecessary grid repaint
Browse files Browse the repository at this point in the history
  • Loading branch information
sevein committed Jun 28, 2024
1 parent 32766a3 commit 8685a56
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/dashboard/src/media/js/jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -861,13 +861,24 @@ BaseAppView = Backbone.View.extend({
}
},

// Check if the response from the API has changed since the last poll.
hasResponseChanged: function(response)
{
var changed = this.firstPoll || this.previousVersion !== response;

this.previousVersion = response;

return changed;
},

poll: function(start)
{
this.firstPoll = undefined !== start;

$.ajax({
context: this,
dataType: 'json',
// Use text instead of json to cache raw bytes. We'll parse manually.
dataType: 'text',
type: 'GET',
url: this.statusUrl + '?' + new Date().getTime(),
beforeSend: function()
Expand All @@ -880,7 +891,12 @@ BaseAppView = Backbone.View.extend({
},
success: function(response)
{
var objects = response.objects;
if (!this.hasResponseChanged(response)) {
return;
}

var data = JSON.parse(response);
var objects = data.objects;

if (getURLParameter('paged'))
{
Expand Down Expand Up @@ -920,7 +936,7 @@ BaseAppView = Backbone.View.extend({
}

// MCP status
if (response.mcp)
if (data.mcp)
{
window.statusWidget.connect();
}
Expand Down

0 comments on commit 8685a56

Please sign in to comment.