Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
7af73c34
Commit
7af73c34
authored
Nov 18, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use getter to lazily create Strophe.Connection
parent
86593dc3
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
100 additions
and
107 deletions
+100
-107
dist/converse.js
dist/converse.js
+37
-32
spec/converse.js
spec/converse.js
+13
-22
spec/login.js
spec/login.js
+2
-2
spec/register.js
spec/register.js
+12
-14
src/converse-controlbox.js
src/converse-controlbox.js
+3
-4
src/converse-minimize.js
src/converse-minimize.js
+2
-4
src/converse-rosterview.js
src/converse-rosterview.js
+1
-1
src/headless/converse-core.js
src/headless/converse-core.js
+29
-27
tests/utils.js
tests/utils.js
+1
-1
No files found.
dist/converse.js
View file @
7af73c34
...
@@ -51479,7 +51479,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_5__["default"].plugins
...
@@ -51479,7 +51479,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_5__["default"].plugins
}
}
});
});
Promise.all([_converse.api.waitUntil('connectionInitialized'), _converse.api.waitUntil('chatBoxViewsInitialized')]
).then(_converse.addControlBox).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
_converse.api.waitUntil('chatBoxViewsInitialized'
).then(_converse.addControlBox).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
_converse.on('chatBoxesFetched', () => {
_converse.on('chatBoxesFetched', () => {
const controlbox = _converse.chatboxes.get('controlbox') || _converse.addControlBox();
const controlbox = _converse.chatboxes.get('controlbox') || _converse.addControlBox();
...
@@ -53126,7 +53126,8 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_1__["default"].plugins
...
@@ -53126,7 +53126,8 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_1__["default"].plugins
}
}
});
});
Promise.all([_converse.api.waitUntil('connectionInitialized'), _converse.api.waitUntil('chatBoxViewsInitialized')]).then(() => {
_converse.api.waitUntil('chatBoxViewsInitialized').then(() => {
_converse.minimized_chats = new _converse.MinimizedChats({
_converse.minimized_chats = new _converse.MinimizedChats({
model: _converse.chatboxes
model: _converse.chatboxes
});
});
...
@@ -59688,7 +59689,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_5__["default"].plugins
...
@@ -59688,7 +59689,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_5__["default"].plugins
_converse.on('rosterGroupsFetched', this.sortAndPositionAllItems.bind(this));
_converse.on('rosterGroupsFetched', this.sortAndPositionAllItems.bind(this));
_converse.on('rosterContactsFetched', () => {
_converse.on('rosterContactsFetched', () => {
_converse.roster.each(c
ontact => this.addRosterContact(contact
, {
_converse.roster.each(c
=> this.addRosterContact(c
, {
'silent': true
'silent': true
}));
}));
...
@@ -62536,7 +62537,32 @@ const BOSH_WAIT = 59;
...
@@ -62536,7 +62537,32 @@ const BOSH_WAIT = 59;
const _converse = {
const _converse = {
'templates': {},
'templates': {},
'promises': {}
'promises': {},
get connection() {
/* Creates a new Strophe.Connection instance if we don't already have one.
*/
if (!this._connection) {
if (!this.bosh_service_url && !this.websocket_url) {
throw new Error("connection: you must supply a value for either the bosh_service_url or websocket_url or both.");
}
if (('WebSocket' in window || 'MozWebSocket' in window) && this.websocket_url) {
this._connection = new strophe_js__WEBPACK_IMPORTED_MODULE_0__["Strophe"].Connection(this.websocket_url, this.connection_options);
} else if (this.bosh_service_url) {
this._connection = new strophe_js__WEBPACK_IMPORTED_MODULE_0__["Strophe"].Connection(this.bosh_service_url, _lodash_noconflict__WEBPACK_IMPORTED_MODULE_4___default.a.assignIn(this.connection_options, {
'keepalive': this.keepalive
}));
} else {
throw new Error("connection: this browser does not support websockets and bosh_service_url wasn't specified.");
}
_converse.emit('connectionInitialized');
}
return this._connection;
}
};
};
_converse.VERSION_NAME = "v4.0.5";
_converse.VERSION_NAME = "v4.0.5";
...
@@ -62821,28 +62847,6 @@ function initClientConfig() {
...
@@ -62821,28 +62847,6 @@ function initClientConfig() {
_converse.emit('clientConfigInitialized');
_converse.emit('clientConfigInitialized');
}
}
_converse.initConnection = function () {
/* Creates a new Strophe.Connection instance if we don't already have one.
*/
if (!_converse.connection) {
if (!_converse.bosh_service_url && !_converse.websocket_url) {
throw new Error("initConnection: you must supply a value for either the bosh_service_url or websocket_url or both.");
}
if (('WebSocket' in window || 'MozWebSocket' in window) && _converse.websocket_url) {
_converse.connection = new strophe_js__WEBPACK_IMPORTED_MODULE_0__["Strophe"].Connection(_converse.websocket_url, _converse.connection_options);
} else if (_converse.bosh_service_url) {
_converse.connection = new strophe_js__WEBPACK_IMPORTED_MODULE_0__["Strophe"].Connection(_converse.bosh_service_url, _lodash_noconflict__WEBPACK_IMPORTED_MODULE_4___default.a.assignIn(_converse.connection_options, {
'keepalive': _converse.keepalive
}));
} else {
throw new Error("initConnection: this browser does not support websockets and bosh_service_url wasn't specified.");
}
}
_converse.emit('connectionInitialized');
};
function setUpXMLLogging() {
function setUpXMLLogging() {
strophe_js__WEBPACK_IMPORTED_MODULE_0__["Strophe"].log = function (level, msg) {
strophe_js__WEBPACK_IMPORTED_MODULE_0__["Strophe"].log = function (level, msg) {
_converse.log(msg, level);
_converse.log(msg, level);
...
@@ -62862,9 +62866,6 @@ function setUpXMLLogging() {
...
@@ -62862,9 +62866,6 @@ function setUpXMLLogging() {
function finishInitialization() {
function finishInitialization() {
initPlugins();
initPlugins();
initClientConfig();
initClientConfig();
_converse.initConnection();
setUpXMLLogging();
setUpXMLLogging();
_converse.logIn();
_converse.logIn();
...
@@ -62880,6 +62881,8 @@ function finishInitialization() {
...
@@ -62880,6 +62881,8 @@ function finishInitialization() {
_converse.api.disco.own.features.add(strophe_js__WEBPACK_IMPORTED_MODULE_0__["Strophe"].NS.IDLE);
_converse.api.disco.own.features.add(strophe_js__WEBPACK_IMPORTED_MODULE_0__["Strophe"].NS.IDLE);
});
});
}
}
_converse.initialized = true;
}
}
function cleanup() {
function cleanup() {
...
@@ -62900,7 +62903,9 @@ function cleanup() {
...
@@ -62900,7 +62903,9 @@ function cleanup() {
delete _converse.controlboxtoggle;
delete _converse.controlboxtoggle;
delete _converse.chatboxviews;
delete _converse.chatboxviews;
_converse.connection.reset();
if (_converse._connection) {
_converse._connection.reset();
}
_converse.stopListening();
_converse.stopListening();
...
@@ -62918,7 +62923,7 @@ _converse.initialize = function (settings, callback) {
...
@@ -62918,7 +62923,7 @@ _converse.initialize = function (settings, callback) {
_lodash_noconflict__WEBPACK_IMPORTED_MODULE_4___default.a.each(PROMISES, addPromise);
_lodash_noconflict__WEBPACK_IMPORTED_MODULE_4___default.a.each(PROMISES, addPromise);
if (
!_lodash_noconflict__WEBPACK_IMPORTED_MODULE_4___default.a.isUndefined(_converse.connection)
) {
if (
_converse.initialized
) {
cleanup();
cleanup();
}
}
...
@@ -63766,7 +63771,7 @@ _converse.initialize = function (settings, callback) {
...
@@ -63766,7 +63771,7 @@ _converse.initialize = function (settings, callback) {
if (settings.connection) {
if (settings.connection) {
this.connection = settings.connection;
this.
_
connection = settings.connection;
}
}
if (!_lodash_noconflict__WEBPACK_IMPORTED_MODULE_4___default.a.isUndefined(_converse.connection) && _converse.connection.service === 'jasmine tests') {
if (!_lodash_noconflict__WEBPACK_IMPORTED_MODULE_4___default.a.isUndefined(_converse.connection) && _converse.connection.service === 'jasmine tests') {
spec/converse.js
View file @
7af73c34
...
@@ -12,20 +12,24 @@
...
@@ -12,20 +12,24 @@
describe
(
"
Authentication
"
,
function
()
{
describe
(
"
Authentication
"
,
function
()
{
it
(
"
needs either a bosh_service_url a websocket_url or both
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
needs either a bosh_service_url a websocket_url or both
"
,
mock
.
initConverse
(
function
(
_converse
)
{
var
url
=
_converse
.
bosh_service_url
;
const
url
=
_converse
.
bosh_service_url
;
var
connection
=
_converse
.
connection
;
delete
_converse
.
bosh_service_url
;
delete
_converse
.
bosh_service_url
;
delete
_converse
.
connection
;
delete
_converse
.
_connection
;
expect
(
_converse
.
initConnection
).
toThrow
(
let
err
;
new
Error
(
"
initConnection: you must supply a value for either the bosh_service_url or websocket_url or both.
"
));
try
{
_converse
.
bosh_service_url
=
url
;
_converse
.
connection
;
_converse
.
connection
=
connection
;
}
catch
(
e
)
{
err
=
e
;
}
expect
(
_
.
get
(
err
,
'
message
'
))
.
toBe
(
"
connection: you must supply a value for either the bosh_service_url or websocket_url or both.
"
);
}));
}));
describe
(
"
with prebind
"
,
function
()
{
describe
(
"
with prebind
"
,
function
()
{
it
(
"
needs a jid when also using keepalive
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
needs a jid when also using keepalive
"
,
mock
.
initConverse
(
function
(
_converse
)
{
var
authentication
=
_converse
.
authentication
;
const
authentication
=
_converse
.
authentication
;
var
jid
=
_converse
.
jid
;
const
jid
=
_converse
.
jid
;
delete
_converse
.
jid
;
delete
_converse
.
jid
;
_converse
.
keepalive
=
true
;
_converse
.
keepalive
=
true
;
_converse
.
authentication
=
"
prebind
"
;
_converse
.
authentication
=
"
prebind
"
;
...
@@ -33,9 +37,6 @@
...
@@ -33,9 +37,6 @@
new
Error
(
new
Error
(
"
restoreBOSHSession: tried to restore a
\"
keepalive
\"
session
"
+
"
restoreBOSHSession: tried to restore a
\"
keepalive
\"
session
"
+
"
but we don't have the JID for the user!
"
));
"
but we don't have the JID for the user!
"
));
_converse
.
authentication
=
authentication
;
_converse
.
jid
=
jid
;
_converse
.
keepalive
=
false
;
}));
}));
it
(
"
needs jid, rid and sid values when not using keepalive
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
needs jid, rid and sid values when not using keepalive
"
,
mock
.
initConverse
(
function
(
_converse
)
{
...
@@ -208,30 +209,20 @@
...
@@ -208,30 +209,20 @@
it
(
"
has a method for retrieving the next RID
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
has a method for retrieving the next RID
"
,
mock
.
initConverse
(
function
(
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
var
old_connection
=
_converse
.
connection
;
_converse
.
connection
.
_proto
.
rid
=
'
1234
'
;
_converse
.
connection
.
_proto
.
rid
=
'
1234
'
;
_converse
.
expose_rid_and_sid
=
false
;
_converse
.
expose_rid_and_sid
=
false
;
expect
(
_converse
.
api
.
tokens
.
get
(
'
rid
'
)).
toBe
(
null
);
expect
(
_converse
.
api
.
tokens
.
get
(
'
rid
'
)).
toBe
(
null
);
_converse
.
expose_rid_and_sid
=
true
;
_converse
.
expose_rid_and_sid
=
true
;
expect
(
_converse
.
api
.
tokens
.
get
(
'
rid
'
)).
toBe
(
'
1234
'
);
expect
(
_converse
.
api
.
tokens
.
get
(
'
rid
'
)).
toBe
(
'
1234
'
);
_converse
.
connection
=
undefined
;
expect
(
_converse
.
api
.
tokens
.
get
(
'
rid
'
)).
toBe
(
null
);
// Restore the connection
_converse
.
connection
=
old_connection
;
}));
}));
it
(
"
has a method for retrieving the SID
"
,
mock
.
initConverse
(
function
(
_converse
)
{
it
(
"
has a method for retrieving the SID
"
,
mock
.
initConverse
(
function
(
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
var
old_connection
=
_converse
.
connection
;
_converse
.
connection
.
_proto
.
sid
=
'
1234
'
;
_converse
.
connection
.
_proto
.
sid
=
'
1234
'
;
_converse
.
expose_rid_and_sid
=
false
;
_converse
.
expose_rid_and_sid
=
false
;
expect
(
_converse
.
api
.
tokens
.
get
(
'
sid
'
)).
toBe
(
null
);
expect
(
_converse
.
api
.
tokens
.
get
(
'
sid
'
)).
toBe
(
null
);
_converse
.
expose_rid_and_sid
=
true
;
_converse
.
expose_rid_and_sid
=
true
;
expect
(
_converse
.
api
.
tokens
.
get
(
'
sid
'
)).
toBe
(
'
1234
'
);
expect
(
_converse
.
api
.
tokens
.
get
(
'
sid
'
)).
toBe
(
'
1234
'
);
_converse
.
connection
=
undefined
;
expect
(
_converse
.
api
.
tokens
.
get
(
'
sid
'
)).
toBe
(
null
);
// Restore the connection
_converse
.
connection
=
old_connection
;
}));
}));
});
});
...
...
spec/login.js
View file @
7af73c34
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
it
(
"
contains a checkbox to indicate whether the computer is trusted or not
"
,
it
(
"
contains a checkbox to indicate whether the computer is trusted or not
"
,
mock
.
initConverseWithPromises
(
mock
.
initConverseWithPromises
(
null
,
[
'
c
onnectionInitialized
'
,
'
c
hatBoxesInitialized
'
],
null
,
[
'
chatBoxesInitialized
'
],
{
auto_login
:
false
,
{
auto_login
:
false
,
allow_registration
:
false
},
allow_registration
:
false
},
function
(
done
,
_converse
)
{
function
(
done
,
_converse
)
{
...
@@ -44,7 +44,7 @@
...
@@ -44,7 +44,7 @@
it
(
"
checkbox can be set to false by default
"
,
it
(
"
checkbox can be set to false by default
"
,
mock
.
initConverseWithPromises
(
mock
.
initConverseWithPromises
(
null
,
[
'
c
onnectionInitialized
'
,
'
c
hatBoxesInitialized
'
],
null
,
[
'
chatBoxesInitialized
'
],
{
auto_login
:
false
,
{
auto_login
:
false
,
trusted
:
false
,
trusted
:
false
,
allow_registration
:
false
},
allow_registration
:
false
},
...
...
spec/register.js
View file @
7af73c34
...
@@ -9,23 +9,21 @@
...
@@ -9,23 +9,21 @@
it
(
"
is not available unless allow_registration=true
"
,
it
(
"
is not available unless allow_registration=true
"
,
mock
.
initConverseWithPromises
(
mock
.
initConverseWithPromises
(
null
,
[
'
c
onnectionInitialized
'
,
'
c
hatBoxesInitialized
'
],
null
,
[
'
chatBoxesInitialized
'
],
{
auto_login
:
false
,
{
auto_login
:
false
,
allow_registration
:
false
},
allow_registration
:
false
},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxviews
.
get
(
'
controlbox
'
))
await
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxviews
.
get
(
'
controlbox
'
));
.
then
(
function
()
{
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
var
cbview
=
_converse
.
chatboxviews
.
get
(
'
controlbox
'
);
const
cbview
=
_converse
.
chatboxviews
.
get
(
'
controlbox
'
);
expect
(
$
(
cbview
.
el
.
querySelector
(
'
a.register-account
'
)
).
length
).
toBe
(
0
);
expect
(
cbview
.
el
.
querySelectorAll
(
'
a.register-account
'
).
length
).
toBe
(
0
);
done
();
done
();
});
}));
}));
it
(
"
can be opened by clicking on the registration tab
"
,
it
(
"
can be opened by clicking on the registration tab
"
,
mock
.
initConverseWithPromises
(
mock
.
initConverseWithPromises
(
null
,
[
'
c
onnectionInitialized
'
,
'
c
hatBoxesInitialized
'
],
null
,
[
'
chatBoxesInitialized
'
],
{
auto_login
:
false
,
{
auto_login
:
false
,
allow_registration
:
true
},
allow_registration
:
true
},
function
(
done
,
_converse
)
{
function
(
done
,
_converse
)
{
...
@@ -52,7 +50,7 @@
...
@@ -52,7 +50,7 @@
it
(
"
allows the user to choose an XMPP provider's domain
"
,
it
(
"
allows the user to choose an XMPP provider's domain
"
,
mock
.
initConverseWithPromises
(
mock
.
initConverseWithPromises
(
null
,
[
'
c
onnectionInitialized
'
,
'
c
hatBoxesInitialized
'
],
null
,
[
'
chatBoxesInitialized
'
],
{
auto_login
:
false
,
{
auto_login
:
false
,
allow_registration
:
true
},
allow_registration
:
true
},
function
(
done
,
_converse
)
{
function
(
done
,
_converse
)
{
...
@@ -92,7 +90,7 @@
...
@@ -92,7 +90,7 @@
it
(
"
will render a registration form as received from the XMPP provider
"
,
it
(
"
will render a registration form as received from the XMPP provider
"
,
mock
.
initConverseWithPromises
(
mock
.
initConverseWithPromises
(
null
,
[
'
c
onnectionInitialized
'
,
'
c
hatBoxesInitialized
'
],
null
,
[
'
chatBoxesInitialized
'
],
{
auto_login
:
false
,
{
auto_login
:
false
,
allow_registration
:
true
},
allow_registration
:
true
},
function
(
done
,
_converse
)
{
function
(
done
,
_converse
)
{
...
@@ -151,7 +149,7 @@
...
@@ -151,7 +149,7 @@
it
(
"
will set form_type to legacy and submit it as legacy
"
,
it
(
"
will set form_type to legacy and submit it as legacy
"
,
mock
.
initConverseWithPromises
(
mock
.
initConverseWithPromises
(
null
,
[
'
c
onnectionInitialized
'
,
'
c
hatBoxesInitialized
'
],
null
,
[
'
chatBoxesInitialized
'
],
{
auto_login
:
false
,
{
auto_login
:
false
,
allow_registration
:
true
},
allow_registration
:
true
},
function
(
done
,
_converse
)
{
function
(
done
,
_converse
)
{
...
@@ -212,7 +210,7 @@
...
@@ -212,7 +210,7 @@
it
(
"
will set form_type to xform and submit it as xform
"
,
it
(
"
will set form_type to xform and submit it as xform
"
,
mock
.
initConverseWithPromises
(
mock
.
initConverseWithPromises
(
null
,
[
'
c
onnectionInitialized
'
,
'
c
hatBoxesInitialized
'
],
null
,
[
'
chatBoxesInitialized
'
],
{
auto_login
:
false
,
{
auto_login
:
false
,
allow_registration
:
true
},
allow_registration
:
true
},
function
(
done
,
_converse
)
{
function
(
done
,
_converse
)
{
...
...
src/converse-controlbox.js
View file @
7af73c34
...
@@ -598,10 +598,9 @@ converse.plugins.add('converse-controlbox', {
...
@@ -598,10 +598,9 @@ converse.plugins.add('converse-controlbox', {
}
}
});
});
Promise
.
all
([
_converse
.
api
.
waitUntil
(
'
connectionInitialized
'
),
_converse
.
api
.
waitUntil
(
'
chatBoxViewsInitialized
'
)
_converse
.
api
.
waitUntil
(
'
chatBoxViewsInitialized
'
)
]).
then
(
_converse
.
addControlBox
).
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
));
.
then
(
_converse
.
addControlBox
)
.
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
));
_converse
.
on
(
'
chatBoxesFetched
'
,
()
=>
{
_converse
.
on
(
'
chatBoxesFetched
'
,
()
=>
{
const
controlbox
=
_converse
.
chatboxes
.
get
(
'
controlbox
'
)
||
_converse
.
addControlBox
();
const
controlbox
=
_converse
.
chatboxes
.
get
(
'
controlbox
'
)
||
_converse
.
addControlBox
();
...
...
src/converse-minimize.js
View file @
7af73c34
...
@@ -509,10 +509,8 @@ converse.plugins.add('converse-minimize', {
...
@@ -509,10 +509,8 @@ converse.plugins.add('converse-minimize', {
}
}
});
});
Promise
.
all
([
_converse
.
api
.
waitUntil
(
'
connectionInitialized
'
),
_converse
.
api
.
waitUntil
(
'
chatBoxViewsInitialized
'
)
_converse
.
api
.
waitUntil
(
'
chatBoxViewsInitialized
'
)
])
.
then
(()
=>
{
.
then
(()
=>
{
_converse
.
minimized_chats
=
new
_converse
.
MinimizedChats
({
_converse
.
minimized_chats
=
new
_converse
.
MinimizedChats
({
model
:
_converse
.
chatboxes
model
:
_converse
.
chatboxes
});
});
...
...
src/converse-rosterview.js
View file @
7af73c34
...
@@ -782,7 +782,7 @@ converse.plugins.add('converse-rosterview', {
...
@@ -782,7 +782,7 @@ converse.plugins.add('converse-rosterview', {
_converse
.
on
(
'
rosterGroupsFetched
'
,
this
.
sortAndPositionAllItems
.
bind
(
this
));
_converse
.
on
(
'
rosterGroupsFetched
'
,
this
.
sortAndPositionAllItems
.
bind
(
this
));
_converse
.
on
(
'
rosterContactsFetched
'
,
()
=>
{
_converse
.
on
(
'
rosterContactsFetched
'
,
()
=>
{
_converse
.
roster
.
each
(
(
contact
)
=>
this
.
addRosterContact
(
contact
,
{
'
silent
'
:
true
}));
_converse
.
roster
.
each
(
c
=>
this
.
addRosterContact
(
c
,
{
'
silent
'
:
true
}));
this
.
update
();
this
.
update
();
this
.
updateFilter
();
this
.
updateFilter
();
this
.
trigger
(
'
rosterContactsFetchedAndProcessed
'
);
this
.
trigger
(
'
rosterContactsFetchedAndProcessed
'
);
...
...
src/headless/converse-core.js
View file @
7af73c34
...
@@ -69,7 +69,29 @@ const BOSH_WAIT = 59;
...
@@ -69,7 +69,29 @@ const BOSH_WAIT = 59;
*/
*/
const
_converse
=
{
const
_converse
=
{
'
templates
'
:
{},
'
templates
'
:
{},
'
promises
'
:
{}
'
promises
'
:
{},
get
connection
()
{
/* Creates a new Strophe.Connection instance if we don't already have one.
*/
if
(
!
this
.
_connection
)
{
if
(
!
this
.
bosh_service_url
&&
!
this
.
websocket_url
)
{
throw
new
Error
(
"
connection: you must supply a value for either the bosh_service_url or websocket_url or both.
"
);
}
if
((
'
WebSocket
'
in
window
||
'
MozWebSocket
'
in
window
)
&&
this
.
websocket_url
)
{
this
.
_connection
=
new
Strophe
.
Connection
(
this
.
websocket_url
,
this
.
connection_options
);
}
else
if
(
this
.
bosh_service_url
)
{
this
.
_connection
=
new
Strophe
.
Connection
(
this
.
bosh_service_url
,
_
.
assignIn
(
this
.
connection_options
,
{
'
keepalive
'
:
this
.
keepalive
})
);
}
else
{
throw
new
Error
(
"
connection: this browser does not support websockets and bosh_service_url wasn't specified.
"
);
}
_converse
.
emit
(
'
connectionInitialized
'
);
}
return
this
.
_connection
;
}
}
}
_converse
.
VERSION_NAME
=
"
v4.0.5
"
;
_converse
.
VERSION_NAME
=
"
v4.0.5
"
;
...
@@ -373,27 +395,6 @@ function initClientConfig () {
...
@@ -373,27 +395,6 @@ function initClientConfig () {
_converse
.
emit
(
'
clientConfigInitialized
'
);
_converse
.
emit
(
'
clientConfigInitialized
'
);
}
}
_converse
.
initConnection
=
function
()
{
/* Creates a new Strophe.Connection instance if we don't already have one.
*/
if
(
!
_converse
.
connection
)
{
if
(
!
_converse
.
bosh_service_url
&&
!
_converse
.
websocket_url
)
{
throw
new
Error
(
"
initConnection: you must supply a value for either the bosh_service_url or websocket_url or both.
"
);
}
if
((
'
WebSocket
'
in
window
||
'
MozWebSocket
'
in
window
)
&&
_converse
.
websocket_url
)
{
_converse
.
connection
=
new
Strophe
.
Connection
(
_converse
.
websocket_url
,
_converse
.
connection_options
);
}
else
if
(
_converse
.
bosh_service_url
)
{
_converse
.
connection
=
new
Strophe
.
Connection
(
_converse
.
bosh_service_url
,
_
.
assignIn
(
_converse
.
connection_options
,
{
'
keepalive
'
:
_converse
.
keepalive
})
);
}
else
{
throw
new
Error
(
"
initConnection: this browser does not support websockets and bosh_service_url wasn't specified.
"
);
}
}
_converse
.
emit
(
'
connectionInitialized
'
);
}
function
setUpXMLLogging
()
{
function
setUpXMLLogging
()
{
Strophe
.
log
=
function
(
level
,
msg
)
{
Strophe
.
log
=
function
(
level
,
msg
)
{
...
@@ -413,7 +414,6 @@ function setUpXMLLogging () {
...
@@ -413,7 +414,6 @@ function setUpXMLLogging () {
function
finishInitialization
()
{
function
finishInitialization
()
{
initPlugins
();
initPlugins
();
initClientConfig
();
initClientConfig
();
_converse
.
initConnection
();
setUpXMLLogging
();
setUpXMLLogging
();
_converse
.
logIn
();
_converse
.
logIn
();
_converse
.
registerGlobalEventHandlers
();
_converse
.
registerGlobalEventHandlers
();
...
@@ -425,6 +425,7 @@ function finishInitialization () {
...
@@ -425,6 +425,7 @@ function finishInitialization () {
_converse
.
api
.
disco
.
own
.
features
.
add
(
Strophe
.
NS
.
IDLE
);
_converse
.
api
.
disco
.
own
.
features
.
add
(
Strophe
.
NS
.
IDLE
);
});
});
}
}
_converse
.
initialized
=
true
;
}
}
...
@@ -441,7 +442,9 @@ function cleanup () {
...
@@ -441,7 +442,9 @@ function cleanup () {
}
}
delete
_converse
.
controlboxtoggle
;
delete
_converse
.
controlboxtoggle
;
delete
_converse
.
chatboxviews
;
delete
_converse
.
chatboxviews
;
_converse
.
connection
.
reset
();
if
(
_converse
.
_connection
)
{
_converse
.
_connection
.
reset
();
}
_converse
.
stopListening
();
_converse
.
stopListening
();
_converse
.
tearDown
();
_converse
.
tearDown
();
delete
_converse
.
config
;
delete
_converse
.
config
;
...
@@ -454,7 +457,7 @@ _converse.initialize = function (settings, callback) {
...
@@ -454,7 +457,7 @@ _converse.initialize = function (settings, callback) {
settings
=
!
_
.
isUndefined
(
settings
)
?
settings
:
{};
settings
=
!
_
.
isUndefined
(
settings
)
?
settings
:
{};
const
init_promise
=
u
.
getResolveablePromise
();
const
init_promise
=
u
.
getResolveablePromise
();
_
.
each
(
PROMISES
,
addPromise
);
_
.
each
(
PROMISES
,
addPromise
);
if
(
!
_
.
isUndefined
(
_converse
.
connection
)
)
{
if
(
_converse
.
initialized
)
{
cleanup
();
cleanup
();
}
}
...
@@ -1212,12 +1215,11 @@ _converse.initialize = function (settings, callback) {
...
@@ -1212,12 +1215,11 @@ _converse.initialize = function (settings, callback) {
return
_converse
;
return
_converse
;
};
};
// Initialization
// Initialization
// --------------
// --------------
// This is the end of the initialize method.
// This is the end of the initialize method.
if
(
settings
.
connection
)
{
if
(
settings
.
connection
)
{
this
.
connection
=
settings
.
connection
;
this
.
_
connection
=
settings
.
connection
;
}
}
if
(
!
_
.
isUndefined
(
_converse
.
connection
)
&&
if
(
!
_
.
isUndefined
(
_converse
.
connection
)
&&
...
...
tests/utils.js
View file @
7af73c34
...
@@ -66,7 +66,7 @@
...
@@ -66,7 +66,7 @@
};
};
utils
.
openControlBox
=
function
()
{
utils
.
openControlBox
=
function
()
{
var
toggle
=
document
.
querySelector
(
"
.toggle-controlbox
"
);
const
toggle
=
document
.
querySelector
(
"
.toggle-controlbox
"
);
if
(
!
u
.
isVisible
(
document
.
querySelector
(
"
#controlbox
"
)))
{
if
(
!
u
.
isVisible
(
document
.
querySelector
(
"
#controlbox
"
)))
{
if
(
!
u
.
isVisible
(
toggle
))
{
if
(
!
u
.
isVisible
(
toggle
))
{
u
.
removeClass
(
'
hidden
'
,
toggle
);
u
.
removeClass
(
'
hidden
'
,
toggle
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment