Fetch default recon service in background silently. Fixes #1665

This commit is contained in:
Antonin Delpeuch 2019-12-24 09:07:23 +01:00
parent 1355a373c9
commit ad261109be

View File

@ -62,8 +62,11 @@ ReconciliationManager.registerService = function(service) {
return ReconciliationManager.customServices.length - 1; return ReconciliationManager.customServices.length - 1;
}; };
ReconciliationManager.registerStandardService = function(url, f) { ReconciliationManager.registerStandardService = function(url, f, silent) {
var dismissBusy = DialogSystem.showBusy($.i18n('core-recon/contact-service')+"..."); var dismissBusy = function() {};
if (!silent) {
dismissBusy = DialogSystem.showBusy($.i18n('core-recon/contact-service')+"...");
}
$.ajax( $.ajax(
url, url,
@ -90,8 +93,10 @@ ReconciliationManager.registerStandardService = function(url, f) {
} }
}) })
.error(function(jqXHR, textStatus, errorThrown) { .error(function(jqXHR, textStatus, errorThrown) {
dismissBusy(); if (!silent) {
alert($.i18n('core-recon/error-contact')+': ' + textStatus + ' : ' + errorThrown + ' - ' + url); dismissBusy();
alert($.i18n('core-recon/error-contact')+': ' + textStatus + ' : ' + errorThrown + ' - ' + url);
}
}); });
}; };
@ -132,14 +137,14 @@ ReconciliationManager.save = function(f) {
}); });
}; };
ReconciliationManager.getOrRegisterServiceFromUrl = function(url, f) { ReconciliationManager.getOrRegisterServiceFromUrl = function(url, f, silent) {
var service = ReconciliationManager.getServiceFromUrl(url); var service = ReconciliationManager.getServiceFromUrl(url);
if (service == null) { if (service == null) {
ReconciliationManager.registerStandardService(url, function(idx) { ReconciliationManager.registerStandardService(url, function(idx) {
ReconciliationManager.save(function() { ReconciliationManager.save(function() {
f(ReconciliationManager.standardServices[idx]); f(ReconciliationManager.standardServices[idx]);
}); });
}); }, silent);
} else { } else {
f(service); f(service);
} }
@ -148,7 +153,7 @@ ReconciliationManager.getOrRegisterServiceFromUrl = function(url, f) {
ReconciliationManager.ensureDefaultServicePresent = function() { ReconciliationManager.ensureDefaultServicePresent = function() {
var lang = $.i18n('core-recon/wd-recon-lang'); var lang = $.i18n('core-recon/wd-recon-lang');
var url = "https://tools.wmflabs.org/openrefine-wikidata/"+lang+"/api"; var url = "https://tools.wmflabs.org/openrefine-wikidata/"+lang+"/api";
ReconciliationManager.getOrRegisterServiceFromUrl(url, function(service) { }); ReconciliationManager.getOrRegisterServiceFromUrl(url, function(service) { }, true);
return url; return url;
}; };