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
454f8ef0
Commit
454f8ef0
authored
Jun 09, 2016
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Let converse.initialize return a deferred
and use that in the tests, instead of a callback.
parent
62c17027
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
22 deletions
+13
-22
src/converse-api.js
src/converse-api.js
+1
-1
src/converse-core.js
src/converse-core.js
+11
-18
tests/main.js
tests/main.js
+1
-3
No files found.
src/converse-api.js
View file @
454f8ef0
...
...
@@ -23,7 +23,7 @@
var
Strophe
=
strophe
.
Strophe
;
return
{
'
initialize
'
:
function
(
settings
,
callback
)
{
converse
.
initialize
(
settings
,
callback
);
return
converse
.
initialize
(
settings
,
callback
);
},
'
log
'
:
converse
.
log
,
'
connection
'
:
{
...
...
src/converse-core.js
View file @
454f8ef0
...
...
@@ -132,6 +132,7 @@
converse
.
initialize
=
function
(
settings
,
callback
)
{
"
use strict
"
;
var
init_deferred
=
new
$
.
Deferred
();
var
converse
=
this
;
var
unloadevent
;
if
(
'
onpagehide
'
in
window
)
{
...
...
@@ -621,7 +622,7 @@
};
this
.
onStatusInitialized
=
function
(
deferred
)
{
this
.
onStatusInitialized
=
function
()
{
this
.
registerIntervalHandler
();
this
.
roster
=
new
this
.
RosterContacts
();
this
.
roster
.
browserStorage
=
new
Backbone
.
BrowserStorage
[
this
.
storage
](
...
...
@@ -629,20 +630,9 @@
this
.
chatboxes
.
onConnected
();
this
.
giveFeedback
(
__
(
'
Contacts
'
));
if
(
typeof
this
.
callback
===
'
function
'
)
{
// A callback method may be passed in via the
// converse.initialize method.
// XXX: Can we use $.Deferred instead of this callback?
if
(
this
.
connection
.
service
===
'
jasmine tests
'
)
{
// XXX: Call back with the internal converse object. This
// object should never be exposed to production systems.
// 'jasmine tests' is an invalid http bind service value,
// so we're sure that this is just for tests.
this
.
callback
(
this
);
}
else
{
this
.
callback
();
}
// XXX: Deprecate in favor of init_deferred
this
.
callback
();
}
deferred
.
resolve
();
converse
.
emit
(
'
initialized
'
);
};
...
...
@@ -650,7 +640,6 @@
// When reconnecting, there might be some open chat boxes. We don't
// know whether these boxes are of the same account or not, so we
// close them now.
var
deferred
=
new
$
.
Deferred
();
// XXX: ran into an issue where a returned PubSub BOSH response was
// not received by the browser. The solution was to flush the
// connection early on. I don't know what the underlying cause of
...
...
@@ -670,13 +659,11 @@
this
.
domain
=
Strophe
.
getDomainFromJid
(
this
.
connection
.
jid
);
this
.
features
=
new
this
.
Features
();
this
.
enableCarbons
();
this
.
initStatus
().
done
(
_
.
bind
(
this
.
onStatusInitialized
,
this
,
deferred
));
this
.
initStatus
().
done
(
_
.
bind
(
this
.
onStatusInitialized
,
this
));
converse
.
emit
(
'
connected
'
);
converse
.
emit
(
'
ready
'
);
// BBB: Will be removed.
return
deferred
.
promise
();
};
this
.
RosterContact
=
Backbone
.
Model
.
extend
({
initialize
:
function
(
attributes
,
options
)
{
...
...
@@ -1796,7 +1783,13 @@
}).
then
(
function
()
{
converse
.
_initialize
();
converse
.
registerGlobalEventHandlers
();
if
(
converse
.
connection
.
service
===
'
jasmine tests
'
)
{
init_deferred
.
resolve
(
converse
);
}
else
{
init_deferred
.
resolve
();
}
});
return
init_deferred
.
promise
();
};
return
converse
;
}));
tests/main.js
View file @
454f8ef0
...
...
@@ -56,7 +56,7 @@ require([
jid
:
'
dummy@localhost
'
,
password
:
'
secret
'
,
debug
:
true
}
,
function
(
converse
)
{
}
).
then
(
function
(
converse
)
{
window
.
converse
=
converse
;
window
.
crypto
=
{
getRandomValues
:
function
(
buf
)
{
...
...
@@ -86,8 +86,6 @@ require([
"
spec/register
"
,
"
spec/xmppstatus
"
,
],
function
()
{
// Make sure this callback is only called once.
delete
converse
.
callback
;
// Stub the trimChat method. It causes havoc when running with
// phantomJS.
converse
.
ChatBoxViews
.
prototype
.
trimChat
=
function
()
{};
...
...
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