// Fetches the offline block list and rebuilds the offline blocks
// table from the new data.
function populateBlockList(authtoken) {
- if (buildingBlockList) return;
+
+ if (buildingBlockList) {
+ return Promise.reject('Block list download already in progress');
+ }
+
buildingBlockList = true;
var url = '/standalone/list.txt?ses=' +
}
);
} else {
+ buildingBlockList = false;
reject('Error fetching offline block list');
}
}
function insertOfflineChunks(chunks, offset, resolve, reject) {
var chunk = chunks[offset];
if (!chunk || chunk.length === 0) {
- console.debug('Block list successfully stored');
+ console.debug('Block list store completed');
return resolve();
}
}
});
+ $scope.buildingBlockList = false;
$scope.downloadBlockList = function () {
+ $scope.buildingBlockList = true;
egProgressDialog.open();
egLovefield.populateBlockList().then(
function(){
ngToast.warning(egCore.strings.OFFLINE_BLOCKLIST_FAIL);
egCore.audio.play('warning.offline.blocklist_fail');
}
- )['finally'](egProgressDialog.close);
+ )['finally'](function() {
+ $scope.buildingBlockList = false;
+ egProgressDialog.close();
+ });
}
$scope.createOfflineXactBlob = function () {