Add new option strict_plugin_dependencies

This commit is contained in:
JC Brand 2016-03-14 17:03:48 +00:00
parent 45bc7f1180
commit 80c26e708c
2 changed files with 28 additions and 4 deletions

View File

@ -717,6 +717,20 @@ Data in localStorage on the other hand is kept indefinitely.
roster contact statuses will not become out of sync in a single session,
only across more than one session.
strict_plugin_dependencies
--------------------------
* Default: ``false``
When set to ``true`` and a plugin tries to override an object which doesn't
exist (for example because the plugin which provides that object is not
loaded), then an error will be raised.
Otherwise a message will simply be logged and the override instruction ignored.
This allows plugins to have "soft" dependencies which aren't declared as
as dependencies.
synchronize_availability
--------------------

View File

@ -279,6 +279,7 @@
show_only_online_users: false,
sid: undefined,
storage: 'session',
strict_plugin_dependencies: false,
synchronize_availability: true, // Set to false to not sync with other clients or with resource name of the particular client that it should synchronize with
use_vcards: true,
visible_toolbar_buttons: {
@ -1875,8 +1876,17 @@
/* We automatically override all methods and Backbone views and
* models that are in the "overrides" namespace.
*/
var override = plugin.overrides[key];
var msg,
override = plugin.overrides[key];
if (typeof override === "object") {
if (typeof converse[key] === 'undefined') {
msg = "Error: Plugin tried to override "+key+" but it's not found.";
if (converse.strict_plugin_dependencies) {
throw msg;
} else {
converse.log(msg);
}
}
this._extendObject(converse[key], override);
} else {
this._overrideAttribute(key, plugin);