[Search] Changed search load time

Changed how frequently the search controller
checks for updates. This makes the load icon
dissapear faster, and looks more natural. But,
may affect performance.
Also changed the point at which the loading
status becomes 'true'. Made it earlier, at
the beginning of the controller's update().
This commit is contained in:
shale 2015-07-23 11:43:30 -07:00
parent ebb5474b34
commit 29d5535e7c

View File

@ -36,6 +36,9 @@ define(function () {
loading = false;
function update(timestamp) {
// We are loading results
loading = true;
// Get the results
$scope.results = searchService.getLatestResults(0, numResults);
@ -43,14 +46,14 @@ define(function () {
function waitForLatest() {
var timestamps = searchService.getLatestTimestamps(),
areOld = timestamps.some(function(c) {return c < timestamp;});
// If any of the timestamps are older than the one we made the query with
if (areOld) {
// Then wait and try to update again
loading = true;
searchService.updateResults();
$timeout(waitForLatest, 100);
$timeout(waitForLatest, 50);
} else {
// We got the latest results now
// We got the latest results now (and done loading)
loading = false;
$scope.results = searchService.getLatestResults(0, numResults);
}