Fix sw_vers being run repeatedly in View Output window on macOS

Fixes #3136
This commit is contained in:
Dan Stillman 2023-05-26 01:40:53 -04:00
parent d14d281e7c
commit cd20df8d74

View file

@ -5,8 +5,9 @@ var intervalID;
var stopping = false; var stopping = false;
var scrolling = false; var scrolling = false;
var autoscroll = true; var autoscroll = true;
var sysInfo;
function start() { async function start() {
// If scrolled to the bottom of the page, stay there // If scrolled to the bottom of the page, stay there
document.body.onscroll = function (event) { document.body.onscroll = function (event) {
if (!scrolling) { if (!scrolling) {
@ -15,13 +16,14 @@ function start() {
scrolling = false; scrolling = false;
}; };
updateErrors().then(function () { sysInfo = await Zotero.getSystemInfo();
if (stopping) return; await updateErrors()
addInitialOutput(); if (stopping) return;
Zotero.Debug.addConsoleViewerListener(addLine)
intervalID = setInterval(() => updateErrors(), interval); addInitialOutput();
}); Zotero.Debug.addConsoleViewerListener(addLine)
intervalID = setInterval(() => updateErrors(), interval);
} }
function stop() { function stop() {
@ -34,19 +36,16 @@ function stop() {
} }
function updateErrors() { function updateErrors() {
return Zotero.getSystemInfo() if (stopping) return;
.then(function (sysInfo) {
if (stopping) return; var errors = Zotero.getErrors(true);
var errorStr = errors.length ? errors.join('\n\n') + '\n\n' : '';
var errors = Zotero.getErrors(true);
var errorStr = errors.length ? errors.join('\n\n') + '\n\n' : ''; document.getElementById('errors').textContent = errorStr + sysInfo;
document.getElementById('errors').textContent = errorStr + sysInfo; if (autoscroll) {
scrollToPageBottom();
if (autoscroll) { }
scrollToPageBottom();
}
});
} }
function addInitialOutput() { function addInitialOutput() {