Skip to content

Commit

Permalink
1be97b106ca9b87308ca4fba2e8d8abf795c9213 dev: Stop calling save state…
Browse files Browse the repository at this point in the history
… when loading a state

Jira Issue DD-2301

01d171892df647431a6f7e6d3acc13e29a46ed0d dev: More resetting of flags from previous commit

Jira Issue DD-2301

Sync to source repo @01d171892df647431a6f7e6d3acc13e29a46ed0d
  • Loading branch information
AllanJard committed Sep 23, 2021
1 parent 5047dd5 commit 3e83d1d
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 68 deletions.
2 changes: 1 addition & 1 deletion datatables.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
],
"src-repo": "http://github.com/DataTables/DataTablesSrc",
"last-tag": "1.11.2",
"last-sync": "1eddf57e55486c9e69581f14f77a2c3cd58b43f4"
"last-sync": "01d171892df647431a6f7e6d3acc13e29a46ed0d"
}
11 changes: 11 additions & 0 deletions js/jquery.dataTables.js
Original file line number Diff line number Diff line change
Expand Up @@ -6382,6 +6382,11 @@
*/
function _fnSaveState ( settings )
{
if (settings._bLoadingState) {
console.log(settings._bLoadingState)
return;
}

/* Store the interesting variables */
var state = {
time: +new Date(),
Expand Down Expand Up @@ -6438,12 +6443,14 @@
function _fnImplementState ( settings, s, callback) {
var i, ien;
var columns = settings.aoColumns;
settings._bLoadingState = true;

// When StateRestore was introduced the state could now be implemented at any time
// Not just initialisation. To do this an api instance is required in some places
var api = settings._bInitComplete ? new DataTable.Api(settings) : null;

if ( ! s || ! s.time ) {
settings._bLoadingState = false;
callback();
return;
}
Expand All @@ -6452,19 +6459,22 @@
// cancelling of loading by returning false
var abStateLoad = _fnCallbackFire( settings, 'aoStateLoadParams', 'stateLoadParams', [settings, s] );
if ( $.inArray( false, abStateLoad ) !== -1 ) {
settings._bLoadingState = false;
callback();
return;
}

// Reject old data
var duration = settings.iStateDuration;
if ( duration > 0 && s.time < +new Date() - (duration*1000) ) {
settings._bLoadingState = false;
callback();
return;
}

// Number of columns have changed - all bets are off, no restore of settings
if ( s.columns && columns.length !== s.columns.length ) {
settings._bLoadingState = false;
callback();
return;
}
Expand Down Expand Up @@ -6529,6 +6539,7 @@
}
}

settings._bLoadingState = false;
_fnCallbackFire( settings, 'aoStateLoaded', 'stateLoaded', [settings, s] );
callback();
};
Expand Down
Loading

0 comments on commit 3e83d1d

Please sign in to comment.