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
5f041769
Commit
5f041769
authored
May 20, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clear messages when converse reconnects
parent
886ff1bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
20 deletions
+19
-20
src/headless/converse-muc.js
src/headless/converse-muc.js
+19
-20
No files found.
src/headless/converse-muc.js
View file @
5f041769
...
...
@@ -1490,18 +1490,6 @@ converse.plugins.add('converse-muc', {
_converse
.
api
.
trigger
(
'
roomsAutoJoined
'
);
}
function
disconnectChatRooms
()
{
/* When disconnecting, mark all groupchats as
* disconnected, so that they will be properly entered again
* when fetched from session storage.
*/
_converse
.
chatboxes
.
each
(
model
=>
{
if
(
model
.
get
(
'
type
'
)
===
_converse
.
CHATROOMS_TYPE
)
{
model
.
save
(
'
connection_status
'
,
converse
.
ROOMSTATUS
.
DISCONNECTED
);
}
});
}
/************************ BEGIN Event Handlers ************************/
_converse
.
api
.
listen
.
on
(
'
addClientFeatures
'
,
()
=>
{
...
...
@@ -1513,13 +1501,23 @@ converse.plugins.add('converse-muc', {
}
});
_converse
.
api
.
listen
.
on
(
'
chatBoxesFetched
'
,
autoJoinRooms
);
function
disconnectChatRooms
()
{
/* When disconnecting, mark all groupchats as
* disconnected, so that they will be properly entered again
* when fetched from session storage.
*/
return
_converse
.
chatboxes
.
filter
(
m
=>
(
m
.
get
(
'
type
'
)
===
_converse
.
CHATROOMS_TYPE
))
.
forEach
(
m
=>
m
.
save
(
'
connection_status
'
,
converse
.
ROOMSTATUS
.
DISCONNECTED
))
}
_converse
.
api
.
listen
.
on
(
'
disconnecting
'
,
disconnectChatRooms
);
_converse
.
api
.
listen
.
on
(
'
statusInitialized
'
,
()
=>
{
// XXX: For websocket connections, we disconnect from all
// chatrooms when the page reloads. This is a workaround for
// issue #1111 and should be removed once we support XEP-0198
const
options
=
{
'
once
'
:
true
,
'
passive
'
:
true
};
window
.
addEventListener
(
_converse
.
unloadevent
,
()
=>
{
if
(
_converse
.
connection
.
_proto
instanceof
Strophe
.
Websocket
)
{
disconnectChatRooms
();
...
...
@@ -1531,13 +1529,14 @@ converse.plugins.add('converse-muc', {
/* Upon a reconnection event from converse, join again
* all the open groupchats.
*/
_converse
.
chatboxes
.
each
(
model
=>
{
if
(
model
.
get
(
'
type
'
)
===
_converse
.
CHATROOMS_TYPE
)
{
model
.
save
(
'
connection_status
'
,
converse
.
ROOMSTATUS
.
DISCONNECTED
);
model
.
registerHandlers
();
model
.
join
();
}
});
_converse
.
chatboxes
.
filter
(
m
=>
(
m
.
get
(
'
type
'
)
===
_converse
.
CHATROOMS_TYPE
))
.
forEach
(
m
=>
m
.
save
(
'
connection_status
'
,
converse
.
ROOMSTATUS
.
DISCONNECTED
))
.
forEach
(
room
=>
{
room
.
clearMessages
();
room
.
registerHandlers
();
room
.
join
();
});
}
_converse
.
api
.
listen
.
on
(
'
reconnected
'
,
reconnectToChatRooms
);
/************************ END Event Handlers ************************/
...
...
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