From 94775dd8589c605347bff2eb55155751521db9f3 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 20 Jul 2016 17:13:11 +0200 Subject: [PATCH] if "common" prefs are not loaded, do not display page generation time Before we queried page_generation_time common preference without a callback, which send a synchronious request to server to fetch common preferences, when it returned it looked for the preference again and send the next synchronious request to the server, in an infinit loop. Now setting _callback parameter of egw.preference() to false, just returns undefined, if common preferences are not yet loaded, but dont try to query them from server --- api/js/jsapi/egw_json.js | 2 +- api/js/jsapi/egw_preferences.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/api/js/jsapi/egw_json.js b/api/js/jsapi/egw_json.js index 9d3ede1b68..fe86c52c27 100644 --- a/api/js/jsapi/egw_json.js +++ b/api/js/jsapi/egw_json.js @@ -146,7 +146,7 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd) json_request.prototype.handleResponse = function(data) { if (data && typeof data.response != 'undefined') { - if (egw.preference('show_generation_time', 'common') == "1") + if (egw.preference('show_generation_time', 'common', false) == "1") { var gen_time_div = jQuery('#divGenTime').length > 0 ? jQuery('#divGenTime') :jQuery('
').appendTo('#egw_fw_footer'); diff --git a/api/js/jsapi/egw_preferences.js b/api/js/jsapi/egw_preferences.js index 6e1ddd1a42..e596d094ac 100644 --- a/api/js/jsapi/egw_preferences.js +++ b/api/js/jsapi/egw_preferences.js @@ -55,7 +55,8 @@ egw.extend('preferences', egw.MODULE_GLOBAL, function() * * @param {string} _name name of the preference, eg. 'dateformat', or '*' to get all the application's preferences * @param {string} _app default 'common' - * @param {function} _callback optional callback, if preference needs loading first + * @param {function|false|undefined} _callback optional callback, if preference needs loading first + * if false given and preference is not loaded, undefined is return and no (synchronious) request is send to server * @param {object} _context context for callback * @return string|bool preference value or false, if callback given and preference not yet loaded */ @@ -65,6 +66,7 @@ egw.extend('preferences', egw.MODULE_GLOBAL, function() if (typeof prefs[_app] == 'undefined') { + if (_callback === false) return undefined; var request = this.json('EGroupware\\Api\\Framework::ajax_get_preference', [_app], _callback, _context); request.sendRequest(typeof _callback == 'function', 'GET'); // use synchronous (cachable) GET request if (typeof prefs[_app] == 'undefined') prefs[_app] = {};