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
796582d9
Commit
796582d9
authored
Jul 18, 2015
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring: got rid of the maybeFetchArchivedMessages method.
updates #306
parent
3b2b4ed6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
21 deletions
+9
-21
converse.js
converse.js
+9
-21
No files found.
converse.js
View file @
796582d9
...
@@ -1313,7 +1313,7 @@
...
@@ -1313,7 +1313,7 @@
if
(
!
converse
.
features
.
findWhere
({
'
var
'
:
Strophe
.
NS
.
MAM
}))
{
if
(
!
converse
.
features
.
findWhere
({
'
var
'
:
Strophe
.
NS
.
MAM
}))
{
return
;
return
;
}
}
if
(
t
ypeof
this
.
model
.
get
(
'
archived_count
'
)
==
'
undefined
'
)
{
if
(
t
his
.
model
.
messages
.
length
<
converse
.
archived_messages_batch_size
)
{
// Get the amount of archived messages
// Get the amount of archived messages
// Refer to: https://xmpp.org/extensions/xep-0059.html#count
// Refer to: https://xmpp.org/extensions/xep-0059.html#count
API
.
archive
.
query
({
API
.
archive
.
query
({
...
@@ -1321,25 +1321,18 @@
...
@@ -1321,25 +1321,18 @@
'
max
'
:
0
'
max
'
:
0
},
},
function
(
messages
,
attrs
)
{
// On Success
function
(
messages
,
attrs
)
{
// On Success
// Whenever the archived_count attribute changes,
if
(
this
.
model
.
messages
.
length
<
Number
(
attrs
.
count
))
{
// fetchArchivedMessages will be called.
this
.
fetchArchivedMessages
({
this
.
model
.
save
({
'
archived_count
'
:
Number
(
attrs
.
count
)});
'
before
'
:
''
,
// Page backwards from the most recent message
this
.
maybeFetchArchivedMessages
();
'
with
'
:
this
.
model
.
get
(
'
jid
'
),
'
max
'
:
converse
.
archived_messages_batch_size
});
}
}.
bind
(
this
),
}.
bind
(
this
),
function
(
iq
)
{
// On Error
function
(
iq
)
{
// On Error
converse
.
log
(
"
Error occured while trying to fetch the archived messages count
"
,
"
error
"
);
converse
.
log
(
"
Error occured while trying to fetch the archived messages count
"
,
"
error
"
);
this
.
model
.
save
({
'
archived_count
'
:
0
});
}.
bind
(
this
)
}.
bind
(
this
)
);
);
}
else
{
this
.
maybeFetchArchivedMessages
();
}
},
maybeFetchArchivedMessages
:
function
()
{
if
(
this
.
model
.
messages
.
length
<
this
.
model
.
get
(
'
archived_count
'
)
&&
this
.
model
.
messages
.
length
<
converse
.
archived_messages_batch_size
)
{
this
.
fetchArchivedMessages
();
}
}
},
},
...
@@ -1349,12 +1342,7 @@
...
@@ -1349,12 +1342,7 @@
* Then, upon receiving them, call onMessage on the chat box,
* Then, upon receiving them, call onMessage on the chat box,
* so that they are displayed inside it.
* so that they are displayed inside it.
*/
*/
API
.
archive
.
query
(
API
.
archive
.
query
(
options
,
options
||
{
'
before
'
:
''
,
// Page backwards from the most recent message
'
with
'
:
this
.
model
.
get
(
'
jid
'
),
'
max
'
:
converse
.
archived_messages_batch_size
},
_
.
partial
(
_
.
map
,
_
,
converse
.
chatboxes
.
onMessage
.
bind
(
converse
.
chatboxes
)),
_
.
partial
(
_
.
map
,
_
,
converse
.
chatboxes
.
onMessage
.
bind
(
converse
.
chatboxes
)),
_
.
partial
(
converse
.
log
,
"
Error while trying to fetch archived messages
"
,
"
error
"
)
_
.
partial
(
converse
.
log
,
"
Error while trying to fetch archived messages
"
,
"
error
"
)
);
);
...
...
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