Disable reset translators/styles buttons while in progress

We should have a better progress notification, but this is better than
nothing.
This commit is contained in:
Dan Stillman 2017-06-19 00:43:24 -04:00
parent 26145c3892
commit b590c43edb
3 changed files with 23 additions and 11 deletions

View File

@ -206,7 +206,7 @@ Zotero_Preferences.Advanced = {
},
resetTranslators: function () {
resetTranslators: async function () {
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
@ -221,17 +221,22 @@ Zotero_Preferences.Advanced = {
null, null, null, {});
if (index == 0) {
Zotero.Schema.resetTranslators()
.then(function () {
let button = document.getElementById('reset-translators-button');
button.disabled = true;
try {
await Zotero.Schema.resetTranslators();
if (Zotero_Preferences.Export) {
Zotero_Preferences.Export.populateQuickCopyList();
}
});
}
finally {
button.disabled = false;
}
}
},
resetStyles: function () {
resetStyles: async function () {
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
@ -246,12 +251,17 @@ Zotero_Preferences.Advanced = {
null, null, null, {});
if (index == 0) {
Zotero.Schema.resetStyles()
.then(function () {
let button = document.getElementById('reset-styles-button');
button.disabled = true;
try {
await Zotero.Schema.resetStyles()
if (Zotero_Preferences.Export) {
Zotero_Preferences.Export.populateQuickCopyList();
}
});
}
finally {
button.disabled = false;
}
}
},

View File

@ -210,9 +210,11 @@
<hbox style="display: block">
<button label="&zotero.preferences.dbMaintenance.integrityCheck;"
oncommand="Zotero_Preferences.Advanced.runIntegrityCheck()"/>
<button label="&zotero.preferences.dbMaintenance.resetTranslators;"
<button id="reset-translators-button"
label="&zotero.preferences.dbMaintenance.resetTranslators;"
oncommand="Zotero_Preferences.Advanced.resetTranslators()"/>
<button label="&zotero.preferences.dbMaintenance.resetStyles;"
<button id="reset-styles-button"
label="&zotero.preferences.dbMaintenance.resetStyles;"
oncommand="Zotero_Preferences.Advanced.resetStyles()"/>
</hbox>
</groupbox>

View File

@ -1148,7 +1148,7 @@ Zotero.Schema = new function(){
this.resetStyles = Zotero.Promise.coroutine(function* () {
Zotero.debug("Resetting translators and styles");
Zotero.debug("Resetting styles");
var sql = "DELETE FROM version WHERE schema IN "
+ "('styles', 'repository', 'lastcheck')";