From 3afe5eb8f30ebb9b079ff2080ff56009bc9b8dd7 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Tue, 15 Aug 2017 16:46:55 +0200 Subject: [PATCH] Run the lodash converter only once. --- src/config.js | 1 + src/converse-controlbox.js | 5 ++--- src/converse-muc.js | 5 ++--- src/lodash.fp.js | 6 ++++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/config.js b/src/config.js index 5ee306a48..923fe2629 100644 --- a/src/config.js +++ b/src/config.js @@ -31,6 +31,7 @@ require.config({ "lodash": "node_modules/lodash/lodash", "lodash.converter": "3rdparty/lodash.fp", "lodash.noconflict": "src/lodash.noconflict", + "lodash.fp": "src/lodash.fp", "pluggable": "node_modules/pluggable.js/dist/pluggable", "polyfill": "src/polyfill", "sizzle": "node_modules/jquery/sizzle/dist/sizzle", diff --git a/src/converse-controlbox.js b/src/converse-controlbox.js index 4671c8a89..5c19e060b 100644 --- a/src/converse-controlbox.js +++ b/src/converse-controlbox.js @@ -9,7 +9,7 @@ (function (root, factory) { define(["jquery.noconflict", "converse-core", - "lodash.converter", + "lodash.fp", "tpl!add_contact_dropdown", "tpl!add_contact_form", "tpl!change_status_message", @@ -29,7 +29,7 @@ }(this, function ( $, converse, - lodashConverter, + fp, tpl_add_contact_dropdown, tpl_add_contact_form, tpl_change_status_message, @@ -49,7 +49,6 @@ const USERS_PANEL_ID = 'users'; const CHATBOX_TYPE = 'chatbox'; const { Strophe, Backbone, utils, _, moment } = converse.env; - const fp = lodashConverter(_.runInContext()); converse.plugins.add('converse-controlbox', { diff --git a/src/converse-muc.js b/src/converse-muc.js index f309b5a98..aa3000400 100755 --- a/src/converse-muc.js +++ b/src/converse-muc.js @@ -13,7 +13,7 @@ define([ "jquery.noconflict", "converse-core", - "lodash.converter", + "lodash.fp", "tpl!chatarea", "tpl!chatroom", "tpl!chatroom_disconnect", @@ -39,7 +39,7 @@ }(this, function ( $, converse, - lodashConverter, + fp, tpl_chatarea, tpl_chatroom, tpl_chatroom_disconnect, @@ -66,7 +66,6 @@ const CHATROOMS_TYPE = 'chatroom'; const { Strophe, Backbone, Promise, $iq, $build, $msg, $pres, b64_sha1, sizzle, utils, _, moment } = converse.env; - const fp = lodashConverter(_.runInContext()); // Add Strophe Namespaces Strophe.addNamespace('MUC_ADMIN', Strophe.NS.MUC + "#admin"); diff --git a/src/lodash.fp.js b/src/lodash.fp.js index 49cfe3fb0..ad9739002 100644 --- a/src/lodash.fp.js +++ b/src/lodash.fp.js @@ -1,3 +1,5 @@ -define(['lodash', 'lodash.fpConverter'], function (_, lodashBrowserConvert) { - return lodashBrowserConvert(_.runInContext()); +define(['lodash', 'lodash.converter', 'converse-core'], function (_, lodashConverter, converse) { + const fp = lodashConverter(_.runInContext()); + converse.env.fp = fp; + return fp; });