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
f21abc60
Commit
f21abc60
authored
Oct 15, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
roster: Only fetch from browser storage if already cached
parent
358187f8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
27 deletions
+27
-27
spec/smacks.js
spec/smacks.js
+7
-7
src/headless/converse-roster.js
src/headless/converse-roster.js
+20
-20
No files found.
spec/smacks.js
View file @
f21abc60
...
...
@@ -44,10 +44,6 @@
`<iq from="romeo@montague.lit/orchard" id="
${
iq
.
getAttribute
(
'
id
'
)}
" to="romeo@montague.lit" type="get" xmlns="jabber:client">`
+
`<query xmlns="http://jabber.org/protocol/disco#info"/></iq>`
);
iq
=
IQ_stanzas
.
pop
();
expect
(
Strophe
.
serialize
(
iq
)).
toBe
(
`<iq id="
${
iq
.
getAttribute
(
'
id
'
)}
" type="get" xmlns="jabber:client"><query xmlns="jabber:iq:roster"/></iq>`
);
iq
=
IQ_stanzas
.
pop
();
expect
(
Strophe
.
serialize
(
iq
)).
toBe
(
`<iq from="romeo@montague.lit/orchard" id="
${
iq
.
getAttribute
(
'
id
'
)}
" to="montague.lit" type="get" xmlns="jabber:client">`
+
...
...
@@ -58,6 +54,10 @@
`<iq from="romeo@montague.lit" id="
${
disco_iq
.
getAttribute
(
'
id
'
)}
" to="romeo@montague.lit" type="get" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub"><items node="eu.siacs.conversations.axolotl.devicelist"/></pubsub></iq>`
);
iq
=
IQ_stanzas
.
pop
();
expect
(
Strophe
.
serialize
(
iq
)).
toBe
(
`<iq id="
${
iq
.
getAttribute
(
'
id
'
)}
" type="get" xmlns="jabber:client"><query xmlns="jabber:iq:roster"/></iq>`
);
expect
(
sent_stanzas
.
filter
(
s
=>
(
s
.
nodeName
===
'
r
'
)).
length
).
toBe
(
2
);
expect
(
_converse
.
session
.
get
(
'
unacked_stanzas
'
).
length
).
toBe
(
4
);
...
...
@@ -118,9 +118,9 @@
`<iq from="romeo@montague.lit/orchard" id="
${
iq
.
getAttribute
(
'
id
'
)}
" to="romeo@montague.lit" type="get" xmlns="jabber:client">`
+
`<query xmlns="http://jabber.org/protocol/disco#info"/></iq>`
);
iq
=
IQ_stanzas
.
pop
();
expect
(
Strophe
.
serialize
(
iq
)).
toBe
(
`<iq id="
${
iq
.
getAttribute
(
'
id
'
)}
" type="get" xmlns="jabber:client"><query xmlns="jabber:iq:roster"/></iq>`
);
// We don't fetch the roster again because it's cached.
expect
(
_converse
.
session
.
get
(
'
roster_fetched
'
)).
toBeFalsy
();
expect
(
IQ_stanzas
.
filter
(
iq
=>
sizzle
(
'
query[xmlns="jabber:iq:roster"]
'
,
iq
).
pop
()).
length
).
toBe
(
0
);
await
_converse
.
api
.
waitUntil
(
'
statusInitialized
'
);
done
();
...
...
src/headless/converse-roster.js
View file @
f21abc60
...
...
@@ -438,33 +438,33 @@ converse.plugins.add('converse-roster', {
* @returns {promise} Promise which resolves once the contacts have been fetched.
*/
async
fetchRosterContacts
()
{
let
collection
;
try
{
collection
=
await
new
Promise
((
resolve
,
reject
)
=>
{
if
(
_converse
.
session
.
get
(
'
roster_fetched
'
))
{
const
result
=
await
new
Promise
((
resolve
,
reject
)
=>
{
this
.
fetch
({
'
add
'
:
true
,
'
silent
'
:
true
,
'
success
'
:
resolve
,
'
error
'
:
(
m
,
e
)
=>
reject
(
e
)
'
error
'
:
(
c
,
e
)
=>
reject
(
e
)
});
});
}
catch
(
e
)
{
_converse
.
log
(
e
,
Strophe
.
LogLevel
.
ERROR
);
_converse
.
session
.
set
(
'
roster_fetched
'
,
false
)
}
if
(
_converse
.
session
.
get
(
'
roster_fetched
'
))
{
/**
* The contacts roster has been retrieved from the local cache (`sessionStorage`).
* @event _converse#cachedRoster
* @type { _converse.RosterContacts }
* @example _converse.api.listen.on('cachedRoster', (items) => { ... });
* @example _converse.api.waitUntil('cachedRoster').then(items => { ... });
*/
_converse
.
api
.
trigger
(
'
cachedRoster
'
,
collection
);
}
else
{
_converse
.
send_initial_presence
=
true
;
return
_converse
.
roster
.
fetchFromServer
();
if
(
u
.
isErrorObject
(
result
))
{
_converse
.
log
(
result
,
Strophe
.
LogLevel
.
ERROR
);
_converse
.
session
.
set
(
'
roster_fetched
'
,
false
)
}
else
{
/**
* The contacts roster has been retrieved from the local cache (`sessionStorage`).
* @event _converse#cachedRoster
* @type { _converse.RosterContacts }
* @example _converse.api.listen.on('cachedRoster', (items) => { ... });
* @example _converse.api.waitUntil('cachedRoster').then(items => { ... });
*/
_converse
.
api
.
trigger
(
'
cachedRoster
'
,
result
);
return
;
}
}
_converse
.
send_initial_presence
=
true
;
return
_converse
.
roster
.
fetchFromServer
();
},
subscribeToSuggestedItems
(
msg
)
{
...
...
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