From b590c43edbf1c32d62cf7cdbbb78d0a6817732a6 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 19 Jun 2017 00:43:24 -0400 Subject: [PATCH] Disable reset translators/styles buttons while in progress We should have a better progress notification, but this is better than nothing. --- .../preferences/preferences_advanced.js | 26 +++++++++++++------ .../preferences/preferences_advanced.xul | 6 +++-- chrome/content/zotero/xpcom/schema.js | 2 +- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/chrome/content/zotero/preferences/preferences_advanced.js b/chrome/content/zotero/preferences/preferences_advanced.js index 88ac3fb7b..73b31dbf6 100644 --- a/chrome/content/zotero/preferences/preferences_advanced.js +++ b/chrome/content/zotero/preferences/preferences_advanced.js @@ -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; + } } }, diff --git a/chrome/content/zotero/preferences/preferences_advanced.xul b/chrome/content/zotero/preferences/preferences_advanced.xul index 4ff7531ec..68a9ba93d 100644 --- a/chrome/content/zotero/preferences/preferences_advanced.xul +++ b/chrome/content/zotero/preferences/preferences_advanced.xul @@ -210,9 +210,11 @@