From 1731e0e9508bb2e3ea386825c12a9e009b8548d9 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 22 Jan 2019 10:09:47 +0100 Subject: [PATCH] fix only-send-changed-preferences check for objects before preference values which are objects have been always send again trying to fix "storm" of set_preference() calls by mail splitter --- api/js/jsapi/egw_preferences.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/api/js/jsapi/egw_preferences.js b/api/js/jsapi/egw_preferences.js index f1eac34611..bccc8e779a 100644 --- a/api/js/jsapi/egw_preferences.js +++ b/api/js/jsapi/egw_preferences.js @@ -83,15 +83,26 @@ egw.extend('preferences', egw.MODULE_GLOBAL, function() * * Server will silently ignore setting preferences, if user has no right to do so! * + * Preferences are only send to server, if they are changed! + * * @param {string} _app application name or "common" * @param {string} _name name of the pref * @param {string} _val value of the pref, null, undefined or "" to unset it - * @param {function} _callback Function passed along to the queue, called after preference is set server-side + * @param {function} _callback Function passed along to the queue, called after preference is set server-side, + * IF the preference is changed / has a value different from the current one */ set_preference: function(_app, _name, _val, _callback) { // if there is no change, no need to submit it to server - if (typeof prefs[_app] != 'undefined' && prefs[_app][_name] === _val) return; + if (typeof prefs[_app] != 'undefined') + { + var current = prefs[_app][_name]; + var setting = _val; + // to compare objects we serialize them + if (typeof current == 'object') current = JSON.stringify(current); + if (typeof setting == 'object') setting = JSON.stringify(setting); + if (setting === current) return; + } this.jsonq('EGroupware\\Api\\Framework::ajax_set_preference',[_app, _name, _val], _callback);