Bug 669913 - Viewing Sync quota blocks the entire Options window. r=rnewman

Part 2: Use Service.getStorageInfo in the Quota dialog UI.
This commit is contained in:
Philipp von Weitershausen 2011-07-14 12:13:35 -07:00
Родитель 1b6dfcd1f8
Коммит d5b88fb566
2 изменённых файлов: 24 добавлений и 9 удалений

Просмотреть файл

@ -58,16 +58,21 @@ let gSyncQuota = {
},
loadData: function loadData() {
window.setTimeout(function() {
let usage = Weave.Service.getCollectionUsage();
this._usage_req = Weave.Service.getStorageInfo(Weave.INFO_COLLECTION_USAGE,
function (error, usage) {
delete gSyncQuota._usage_req;
// displayUsageData handles null values, so no need to check 'error'.
gUsageTreeView.displayUsageData(usage);
}, 0);
});
let usageLabel = document.getElementById("usageLabel");
let bundle = this.bundle;
window.setTimeout(function() {
let quota = Weave.Service.getQuota();
if (!quota) {
this._quota_req = Weave.Service.getStorageInfo(Weave.INFO_QUOTA,
function (error, quota) {
delete gSyncQuota._quota_req;
if (error) {
usageLabel.value = bundle.getString("quota.usageError.label");
return;
}
@ -82,7 +87,17 @@ let gSyncQuota = {
let total = gSyncQuota.convertKB(quota[1]);
usageLabel.value = bundle.getFormattedString(
"quota.usagePercentage.label", [percent].concat(used).concat(total));
}, 0);
});
},
onCancel: function onCancel() {
if (this._usage_req) {
this._usage_req.abort();
}
if (this._quota_req) {
this._quota_req.abort();
}
return true;
},
onAccept: function onAccept() {
@ -95,7 +110,7 @@ let gSyncQuota = {
let Service = Weave.Service;
Weave.Utils.nextTick(function() { Service.sync(); });
}
return true;
return this.onCancel();
},
convertKB: function convertKB(value) {

Просмотреть файл

@ -56,7 +56,7 @@
onload="gSyncQuota.init()"
buttons="accept,cancel"
title="&quota.dialogTitle.label;"
ondialogcancel="return true;"
ondialogcancel="return gSyncQuota.onCancel();"
ondialogaccept="return gSyncQuota.onAccept();">
<script type="application/javascript"