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
8a9a0a4b
Commit
8a9a0a4b
authored
Aug 03, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for paging through MAM results when catching up
Fixes #1548
parent
c7b6bb47
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
213 additions
and
9 deletions
+213
-9
CHANGES.md
CHANGES.md
+1
-0
spec/mam.js
spec/mam.js
+190
-1
src/headless/converse-mam.js
src/headless/converse-mam.js
+22
-8
No files found.
CHANGES.md
View file @
8a9a0a4b
...
...
@@ -47,6 +47,7 @@
-
#1524: OMEMO libsignal-protocol.js Invalid signature
-
#1532: Converse reloads on enter pressed in the filter box
-
#1538: Allow adding self as contact
-
#1548: Add support for paging through the MAM results when filling in the blanks
-
#1550: Legitimate carbons being blocked due to erroneous forgery check
-
#1554: Room auto-configuration broke if the config form contained fields with type
`fixed`
-
#1558:
`this.get`
is not a function error when
`forward_messages`
is set to
`true`
.
...
...
spec/mam.js
View file @
8a9a0a4b
This diff is collapsed.
Click to expand it.
src/headless/converse-mam.js
View file @
8a9a0a4b
...
...
@@ -102,14 +102,25 @@ converse.plugins.add('converse-mam', {
}
else
{
message_handler
=
_converse
.
chatboxes
.
onMessage
.
bind
(
_converse
.
chatboxes
)
}
const
result
=
await
_converse
.
api
.
archive
.
query
(
Object
.
assign
({
const
query
=
Object
.
assign
({
'
groupchat
'
:
is_groupchat
,
'
before
'
:
''
,
// Page backwards from the most recent message
'
max
'
:
_converse
.
archived_messages_page_size
,
'
with
'
:
this
.
get
(
'
jid
'
),
},
options
));
},
options
);
const
result
=
await
_converse
.
api
.
archive
.
query
(
query
);
result
.
messages
.
forEach
(
message_handler
);
const
catching_up
=
query
.
before
||
query
.
after
;
if
(
result
.
rsm
)
{
if
(
catching_up
)
{
return
this
.
fetchArchivedMessages
(
result
.
rsm
.
previous
(
_converse
.
archived_messages_page_size
));
}
else
{
// TODO: Add a special kind of message which will
// render as a link to fetch further messages, either
// to fetch older messages or to fill in a gap.
}
}
},
async
findDuplicateFromArchiveID
(
stanza
)
{
...
...
@@ -455,7 +466,7 @@ converse.plugins.add('converse-mam', {
stanza
.
up
();
if
(
options
instanceof
_converse
.
RSM
)
{
stanza
.
cnode
(
options
.
toXML
());
}
else
if
(
_
.
intersection
(
_converse
.
RSM_ATTRIBUTES
,
Object
.
keys
(
options
)).
length
)
{
}
else
if
(
intersection
(
_converse
.
RSM_ATTRIBUTES
,
Object
.
keys
(
options
)).
length
)
{
stanza
.
cnode
(
new
_converse
.
RSM
(
options
).
toXML
());
}
}
...
...
@@ -483,10 +494,13 @@ converse.plugins.add('converse-mam', {
}
_converse
.
connection
.
deleteHandler
(
message_handler
);
const
set
=
iq_result
?
iq_result
.
querySelector
(
'
set
'
)
:
null
;
if
(
set
!==
null
)
{
rsm
=
new
_converse
.
RSM
({
'
xml
'
:
set
});
Object
.
assign
(
rsm
,
_
.
pick
(
options
,
_
.
concat
(
MAM_ATTRIBUTES
,
[
'
max
'
])));
const
fin
=
iq_result
&&
sizzle
(
`fin[xmlns="
${
Strophe
.
NS
.
MAM
}
"]`
,
iq_result
).
pop
();
if
(
fin
&&
[
null
,
'
false
'
].
includes
(
fin
.
getAttribute
(
'
complete
'
)))
{
const
set
=
sizzle
(
`set[xmlns="
${
Strophe
.
NS
.
RSM
}
"]`
,
fin
).
pop
();
if
(
set
)
{
rsm
=
new
_converse
.
RSM
({
'
xml
'
:
set
});
Object
.
assign
(
rsm
,
pick
(
options
,
[...
MAM_ATTRIBUTES
,
...
_converse
.
RSM_ATTRIBUTES
]));
}
}
return
{
messages
,
rsm
}
}
...
...
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