Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions dist/angular-data.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @author Jason Dobry <[email protected]>
* @file angular-data.js
* @version 0.10.1 - Homepage <http://angular-data.pseudobry.com/>
* @version 0.10.2 - Homepage <http://angular-data.pseudobry.com/>
* @copyright (c) 2014 Jason Dobry <https://github.com/jmdobry/>
* @license MIT <https://github.com/jmdobry/angular-data/blob/master/LICENSE>
*
Expand Down Expand Up @@ -2328,13 +2328,20 @@ module.exports = find;
var errorPrefix = 'DS.findAll(resourceName, params[, options]): ';

function processResults(utils, data, resourceName, queryHash) {
var resource = this.store[resourceName];
var resource = this.store[resourceName],
idAttribute = this.definitions[resourceName].idAttribute,
date = new Date().getTime();

data = data || [];

// Query is no longer pending
delete resource.pendingQueries[queryHash];
resource.completedQueries[queryHash] = new Date().getTime();
resource.completedQueries[queryHash] = date;

// Make sure each object is added to completedQueries
angular.forEach(data, function (obj, idx) {
resource.completedQueries[obj[idAttribute]] = date;
});

// Update modified timestamp of collection
resource.collectionModified = utils.updateTimestamp(resource.collectionModified);
Expand Down
6 changes: 3 additions & 3 deletions dist/angular-data.min.js

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions src/datastore/async_methods/findAll.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
var errorPrefix = 'DS.findAll(resourceName, params[, options]): ';

function processResults(utils, data, resourceName, queryHash) {
var resource = this.store[resourceName];
var resource = this.store[resourceName],
idAttribute = this.definitions[resourceName].idAttribute,
date = new Date().getTime();

data = data || [];

// Query is no longer pending
delete resource.pendingQueries[queryHash];
resource.completedQueries[queryHash] = new Date().getTime();
resource.completedQueries[queryHash] = date;

// Make sure each object is added to completedQueries
angular.forEach(data, function (obj, idx) {
resource.completedQueries[obj[idAttribute]] = date;
});

// Update modified timestamp of collection
resource.collectionModified = utils.updateTimestamp(resource.collectionModified);
Expand Down
2 changes: 2 additions & 0 deletions test/integration/datastore/async_methods/findAll.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ describe('DS.findAll(resourceName, params[, options]): ', function () {
assert.deepEqual(DS.filter('post', {}), [p1, p2, p3, p4], 'The posts are now in the store');
assert.isNumber(DS.lastModified('post', 5));
assert.isNumber(DS.lastSaved('post', 5));
DS.find('post', p1.id); // should not trigger another XHR


// Should not make a request because the request was already completed
DS.findAll('post', {}).then(function (data) {
Expand Down