Move ZoteroPane.syncAlert() to Sync.Runner.alert()

And use for sync setup in prefs so that it includes the dialog header
from the sync error messages
This commit is contained in:
Dan Stillman 2024-04-02 05:49:54 -04:00 committed by Dan Stillman
parent c16f5d1524
commit 35aaa013ed
3 changed files with 49 additions and 53 deletions

View file

@ -145,11 +145,7 @@ Zotero_Preferences.Sync = {
}
catch (e) {
setTimeout(function () {
Zotero.alert(
window,
Zotero.getString('general.error'),
e.message
);
Zotero.Sync.Runner.alert(e);
});
throw e;
}

View file

@ -1593,6 +1593,53 @@ Zotero.Sync.Runner_Module = function (options = {}) {
}
this.alert = function (e) {
e = Zotero.Sync.Runner.parseError(e);
var ps = Services.prompt;
var buttonText = e.dialogButtonText;
var buttonCallback = e.dialogButtonCallback;
if (e.errorType == 'warning' || e.errorType == 'error') {
let title = Zotero.getString('general.' + e.errorType);
// TODO: Display header in bold
let msg = (e.dialogHeader ? e.dialogHeader + '\n\n' : '') + e.message;
if (e.errorType == 'warning' || buttonText === null) {
ps.alert(null, title, e.message);
return;
}
if (!buttonText) {
buttonText = Zotero.getString('errorReport.reportError');
buttonCallback = function () {
ZoteroPane.reportErrors();
};
}
let buttonFlags = ps.BUTTON_POS_0 * ps.BUTTON_TITLE_OK
+ ps.BUTTON_POS_1 * ps.BUTTON_TITLE_IS_STRING;
let index = ps.confirmEx(
null,
title,
msg,
buttonFlags,
"",
buttonText,
"", null, {}
);
if (index == 1) {
setTimeout(buttonCallback, 1);
}
}
// Upgrade message
else if (e.errorType == 'upgrade') {
ps.alert(null, "", e.message);
return;
}
};
/**
* Register labels in sync icon tooltip to receive updates
*

View file

@ -4798,7 +4798,7 @@ var ZoteroPane = new function()
catch (e) {
// TODO: show error somewhere else
Zotero.debug(e, 1);
ZoteroPane_Local.syncAlert(e);
Zotero.Sync.Runner.alert(e);
return;
}
@ -5142,53 +5142,6 @@ var ZoteroPane = new function()
};
this.syncAlert = function (e) {
e = Zotero.Sync.Runner.parseError(e);
var ps = Services.prompt;
var buttonText = e.dialogButtonText;
var buttonCallback = e.dialogButtonCallback;
if (e.errorType == 'warning' || e.errorType == 'error') {
let title = Zotero.getString('general.' + e.errorType);
// TODO: Display header in bold
let msg = (e.dialogHeader ? e.dialogHeader + '\n\n' : '') + e.message;
if (e.errorType == 'warning' || buttonText === null) {
ps.alert(null, title, e.message);
return;
}
if (!buttonText) {
buttonText = Zotero.getString('errorReport.reportError');
buttonCallback = function () {
ZoteroPane.reportErrors();
};
}
let buttonFlags = ps.BUTTON_POS_0 * ps.BUTTON_TITLE_OK
+ ps.BUTTON_POS_1 * ps.BUTTON_TITLE_IS_STRING;
let index = ps.confirmEx(
null,
title,
msg,
buttonFlags,
"",
buttonText,
"", null, {}
);
if (index == 1) {
setTimeout(buttonCallback, 1);
}
}
// Upgrade message
else if (e.errorType == 'upgrade') {
ps.alert(null, "", e.message);
return;
}
};
this.recognizeSelected = function() {
Zotero.RecognizeDocument.recognizeItems(ZoteroPane.getSelectedItems());
Zotero.ProgressQueues.get('recognize').getDialog().open();