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
dca0472e
Commit
dca0472e
authored
Jul 12, 2015
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
For archive.query, call callback once after receiving all messages.
updates #306
parent
9abbd1e8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
16 deletions
+13
-16
converse.js
converse.js
+13
-16
No files found.
converse.js
View file @
dca0472e
...
...
@@ -552,32 +552,29 @@
* (XMLElement) iq - The IQ stanza returned from the XMPP server.
* (Object) options - The MAM-specific options of the query ('with', 'start' and 'end')
* (String) queryid - A unique ID sent with the MAM query.
* (Function) callback - A function to call whenever we receive query-relevant stanza.
* (Function) callback - A function to call after we've received all the archived messages.
* If should expect an array of messages and a Strophe.RSM (result set management) object.
*/
var
messages
=
[];
converse
.
connection
.
addHandler
(
function
(
message
)
{
var
rsm
,
$msg
=
$
(
message
);
var
$fin
=
$msg
.
find
(
'
fin[xmlns="
'
+
Strophe
.
NS
.
MAM
+
'
"]
'
);
if
(
$fin
.
length
)
{
rsm
=
new
Strophe
.
RSM
(
_
.
extend
({
xml
:
$fin
.
find
(
'
set
'
)[
0
]},
_
.
pick
(
options
,
MAM_ATTRIBUTES
))
);
callback
(
message
,
rsm
);
return
false
;
// We've received all messages, decommission this handler
}
var
$msg
=
$
(
message
),
$fin
;
if
(
typeof
callback
==
"
function
"
)
{
if
(
queryid
==
$msg
.
find
(
'
result[xmlns="
'
+
Strophe
.
NS
.
MAM
+
'
"]
'
).
attr
(
'
queryid
'
))
{
callback
(
message
);
$fin
=
$msg
.
find
(
'
fin[xmlns="
'
+
Strophe
.
NS
.
MAM
+
'
"]
'
);
if
(
$fin
.
length
)
{
callback
(
messages
,
new
Strophe
.
RSM
(
_
.
extend
({
xml
:
$fin
.
find
(
'
set
'
)[
0
]},
_
.
pick
(
options
,
MAM_ATTRIBUTES
)))
);
return
false
;
// We've received all messages, decommission this handler
}
else
if
(
queryid
==
$msg
.
find
(
'
result[xmlns="
'
+
Strophe
.
NS
.
MAM
+
'
"]
'
).
attr
(
'
queryid
'
))
{
messages
.
push
(
message
);
}
return
true
;
}
else
{
return
false
;
// There's no callback, so no use in continuing this handler.
}
},
null
,
'
message
'
);
if
(
typeof
callback
==
"
function
"
)
{
return
callback
.
apply
(
arguments
);
}
};
this
.
getVCard
=
function
(
jid
,
callback
,
errback
)
{
...
...
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