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
f12c024b
Commit
f12c024b
authored
Jul 29, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't query MAM upon every page load.
Instead we should only query for newly created chats.
parent
8bd72eed
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
2 deletions
+24
-2
src/headless/converse-mam.js
src/headless/converse-mam.js
+16
-2
src/headless/converse-muc.js
src/headless/converse-muc.js
+8
-0
No files found.
src/headless/converse-mam.js
View file @
f12c024b
...
...
@@ -210,10 +210,24 @@ converse.plugins.add('converse-mam', {
}
}
_converse
.
api
.
listen
.
on
(
'
addClientFeatures
'
,
()
=>
_converse
.
api
.
disco
.
own
.
features
.
add
(
Strophe
.
NS
.
MAM
));
_converse
.
api
.
listen
.
on
(
'
serviceDiscovered
'
,
getMAMPrefsFromFeature
);
_converse
.
api
.
listen
.
on
(
'
afterMessagesFetched
'
,
chat
=>
chat
.
fetchNewestMessages
());
_converse
.
api
.
listen
.
on
(
'
chatReconnected
'
,
chat
=>
chat
.
fetchNewestMessages
());
_converse
.
api
.
listen
.
on
(
'
addClientFeatures
'
,
()
=>
_converse
.
api
.
disco
.
own
.
features
.
add
(
Strophe
.
NS
.
MAM
));
_converse
.
api
.
listen
.
on
(
'
enteredNewRoom
'
,
chat
=>
chat
.
fetchNewestMessages
());
_converse
.
api
.
listen
.
on
(
'
afterMessagesFetched
'
,
chat
=>
{
// XXX: We don't want to query MAM every time this is triggered
// since it's not necessary when the chat is restored from cache.
// (given that BOSH or SMACKS will ensure that you get messages
// sent during the reload).
//
// With MUCs we can listen for `enteredNewRoom` but for
// one-on-one we have to use this hacky solutoin for now.
// `chat_state` is `undefined` only for newly created chats.
if
(
chat
.
get
(
'
type
'
)
===
_converse
.
PRIVATE_CHAT_TYPE
&&
chat
.
get
(
'
chat_state
'
)
===
undefined
)
{
chat
.
fetchNewestMessages
();
}
});
_converse
.
api
.
listen
.
on
(
'
chatRoomOpened
'
,
(
room
)
=>
{
room
.
on
(
'
change:mam_enabled
'
,
room
.
fetchArchivedMessagesIfNecessary
,
room
);
...
...
src/headless/converse-muc.js
View file @
f12c024b
...
...
@@ -428,6 +428,14 @@ converse.plugins.add('converse-muc', {
// thereby avoiding re-renders (and therefore DOM reflows).
this
.
fetchMessages
();
/**
* Triggered when the user has entered a new MUC and *after* cached messages have been fetched.
* @event _converse#enteredNewRoom
* @type { _converse.ChatRoom}
* @example _converse.api.listen.on('enteredNewRoom', model => { ... });
*/
_converse
.
api
.
trigger
(
'
enteredNewRoom
'
,
this
);
if
(
_converse
.
auto_register_muc_nickname
&&
await
_converse
.
api
.
disco
.
supports
(
Strophe
.
NS
.
MUC_REGISTER
,
this
.
get
(
'
jid
'
)))
{
this
.
registerNickname
()
...
...
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