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
46fef286
Commit
46fef286
authored
May 16, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clear messages when closing a chat
parent
3085c5d4
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
69 additions
and
15 deletions
+69
-15
spec/messages.js
spec/messages.js
+7
-2
spec/muc.js
spec/muc.js
+30
-3
src/converse-chatview.js
src/converse-chatview.js
+2
-3
src/converse-message-view.js
src/converse-message-view.js
+12
-2
src/converse-muc-views.js
src/converse-muc-views.js
+2
-1
src/headless/converse-chatboxes.js
src/headless/converse-chatboxes.js
+13
-0
src/headless/converse-muc.js
src/headless/converse-muc.js
+3
-4
No files found.
spec/messages.js
View file @
46fef286
...
...
@@ -2265,11 +2265,13 @@
id="5f3dbc5e-e1d3-4077-a492-693f3769c7ad"
by="room@muc.example.com"/>
</message>`
);
spyOn
(
view
.
model
,
'
updateMessage
'
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
await
test_utils
.
waitUntil
(()
=>
view
.
model
.
findDuplicateFromStanzaID
.
calls
.
count
()
===
2
);
result
=
await
view
.
model
.
findDuplicateFromStanzaID
.
calls
.
all
()[
1
].
returnValue
;
expect
(
result
instanceof
_converse
.
Message
).
toBe
(
true
);
expect
(
view
.
model
.
messages
.
length
).
toBe
(
1
);
await
test_utils
.
waitUntil
(()
=>
view
.
model
.
updateMessage
.
calls
.
count
());
done
();
}));
...
...
@@ -2689,7 +2691,10 @@
<acknowledged xmlns="urn:xmpp:chat-markers:0" id="
${
msg_obj
.
get
(
'
msgid
'
)}
"/>
</message>`
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
await
test_utils
.
waitUntil
(()
=>
_converse
.
api
.
trigger
.
calls
.
count
()
===
3
);
spyOn
(
view
.
model
,
"
isChatMarker
"
).
and
.
callThrough
();
await
test_utils
.
waitUntil
(()
=>
view
.
model
.
isChatMarker
.
calls
.
count
()
===
1
);
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg
'
).
length
).
toBe
(
1
);
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg__receipt
'
).
length
).
toBe
(
0
);
expect
(
_converse
.
api
.
trigger
).
toHaveBeenCalledWith
(
'
message
'
,
jasmine
.
any
(
Object
));
...
...
@@ -2701,7 +2706,7 @@
<markable xmlns="urn:xmpp:chat-markers:0"/>
</message>`
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
await
test_utils
.
waitUntil
(()
=>
_converse
.
api
.
trigger
.
calls
.
count
()
===
5
);
await
test_utils
.
waitUntil
(()
=>
view
.
model
.
isChatMarker
.
calls
.
count
()
===
2
);
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg
'
).
length
).
toBe
(
2
);
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg__receipt
'
).
length
).
toBe
(
0
);
expect
(
_converse
.
api
.
trigger
).
toHaveBeenCalledWith
(
'
message
'
,
jasmine
.
any
(
Object
));
...
...
spec/muc.js
View file @
46fef286
...
...
@@ -54,8 +54,8 @@
test_utils
.
createContacts
(
_converse
,
'
current
'
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group .group-toggle
'
).
length
,
300
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
let
jid
=
'
lounge
@localhost
'
;
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
chillout
'
,
'
localhost
'
,
'
dummy
'
);
let
jid
=
'
chillout
@localhost
'
;
let
room
=
_converse
.
api
.
rooms
.
get
(
jid
);
expect
(
room
instanceof
Object
).
toBeTruthy
();
...
...
@@ -87,7 +87,7 @@
chatroomview
.
close
();
// Non-existing room
jid
=
'
lounge
2@localhost
'
;
jid
=
'
chillout
2@localhost
'
;
room
=
_converse
.
api
.
rooms
.
get
(
jid
);
expect
(
typeof
room
===
'
undefined
'
).
toBeTruthy
();
done
();
...
...
@@ -392,6 +392,33 @@
describe
(
"
A Groupchat
"
,
function
()
{
it
(
"
clears cached messages when it gets closed
"
,
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitUntil
(()
=>
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
));
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
const
message
=
'
Hello world
'
,
nick
=
mock
.
chatroom_names
[
0
],
msg
=
$msg
({
'
from
'
:
'
lounge@localhost/
'
+
nick
,
'
id
'
:
(
new
Date
()).
getTime
(),
'
to
'
:
'
dummy@localhost
'
,
'
type
'
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
message
).
tree
();
await
view
.
model
.
onMessage
(
msg
);
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
spyOn
(
view
.
model
,
'
clearMessages
'
).
and
.
callThrough
();
view
.
model
.
close
();
await
test_utils
.
waitUntil
(()
=>
view
.
model
.
clearMessages
.
calls
.
count
());
expect
(
view
.
model
.
messages
.
length
).
toBe
(
0
);
expect
(
view
.
content
.
innerHTML
).
toBe
(
''
);
done
()
}));
it
(
"
is opened when an xmpp: URI is clicked inside another groupchat
"
,
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
...
...
src/converse-chatview.js
View file @
46fef286
...
...
@@ -339,6 +339,7 @@ converse.plugins.add('converse-chatview', {
this
.
initDebounced
();
this
.
model
.
messages
.
on
(
'
add
'
,
this
.
onMessageAdded
,
this
);
this
.
model
.
messages
.
on
(
'
rendered
'
,
this
.
scrollDown
,
this
);
this
.
model
.
messages
.
on
(
'
reset
'
,
()
=>
(
this
.
content
.
innerHTML
=
''
));
this
.
model
.
on
(
'
show
'
,
this
.
show
,
this
);
this
.
model
.
on
(
'
destroy
'
,
this
.
remove
,
this
);
...
...
@@ -1071,9 +1072,7 @@ converse.plugins.add('converse-chatview', {
if
(
ev
&&
ev
.
preventDefault
)
{
ev
.
preventDefault
();
}
const
result
=
confirm
(
__
(
"
Are you sure you want to clear the messages from this conversation?
"
));
if
(
result
===
true
)
{
this
.
content
.
innerHTML
=
''
;
this
.
model
.
messages
.
reset
();
this
.
model
.
messages
.
browserStorage
.
_clear
();
this
.
model
.
clearMessages
();
}
return
this
;
},
...
...
src/converse-message-view.js
View file @
46fef286
...
...
@@ -81,7 +81,13 @@ converse.plugins.add('converse-message-view', {
},
initialize
()
{
this
.
debouncedRender
=
_
.
debounce
(
this
.
render
,
50
);
this
.
debouncedRender
=
_
.
debounce
(()
=>
{
// If the model gets destroyed in the meantime,
// it no longer has a collection
if
(
this
.
model
.
collection
)
{
this
.
render
();
}
},
50
);
if
(
this
.
model
.
vcard
)
{
this
.
model
.
vcard
.
on
(
'
change
'
,
this
.
debouncedRender
,
this
);
}
...
...
@@ -197,7 +203,11 @@ converse.plugins.add('converse-message-view', {
}
await
promise
;
this
.
replaceElement
(
msg
);
this
.
model
.
collection
.
trigger
(
'
rendered
'
,
this
);
if
(
this
.
model
.
collection
)
{
// If the model gets destroyed in the meantime, it no
// longer has a collection.
this
.
model
.
collection
.
trigger
(
'
rendered
'
,
this
);
}
},
renderErrorMessage
()
{
...
...
src/converse-muc-views.js
View file @
46fef286
...
...
@@ -541,6 +541,7 @@ converse.plugins.add('converse-muc-views', {
this
.
model
.
messages
.
on
(
'
add
'
,
this
.
onMessageAdded
,
this
);
this
.
model
.
messages
.
on
(
'
rendered
'
,
this
.
scrollDown
,
this
);
this
.
model
.
messages
.
on
(
'
reset
'
,
()
=>
(
this
.
content
.
innerHTML
=
''
));
this
.
model
.
on
(
'
change:affiliation
'
,
this
.
renderHeading
,
this
);
this
.
model
.
on
(
'
change:connection_status
'
,
this
.
afterConnected
,
this
);
...
...
@@ -1350,7 +1351,7 @@ converse.plugins.add('converse-muc-views', {
this
.
nickname_form
.
model
.
set
(
'
validation_message
'
,
message
);
}
u
.
showElement
(
this
.
nickname_form
.
el
);
this
.
model
.
save
(
'
connection_status
'
,
converse
.
ROOMSTATUS
.
NICKNAME_REQUIRED
);
u
.
safeSave
(
this
.
model
,
{
'
connection_status
'
:
converse
.
ROOMSTATUS
.
NICKNAME_REQUIRED
}
);
},
renderPasswordForm
(
message
=
''
)
{
...
...
src/headless/converse-chatboxes.js
View file @
46fef286
...
...
@@ -331,11 +331,24 @@ converse.plugins.add('converse-chatboxes', {
});
},
clearMessages
()
{
try
{
this
.
messages
.
reset
();
}
catch
(
e
)
{
this
.
messages
.
trigger
(
'
reset
'
);
_converse
.
log
(
e
,
Strophe
.
LogLevel
.
ERROR
);
}
finally
{
this
.
messages
.
browserStorage
.
_clear
();
}
},
close
()
{
try
{
this
.
destroy
();
}
catch
(
e
)
{
_converse
.
log
(
e
,
Strophe
.
LogLevel
.
ERROR
);
}
finally
{
this
.
clearMessages
();
}
},
...
...
src/headless/converse-muc.js
View file @
46fef286
...
...
@@ -243,11 +243,10 @@ converse.plugins.add('converse-muc', {
async
onConnectionStatusChanged
()
{
if
(
this
.
get
(
'
connection_status
'
)
===
converse
.
ROOMSTATUS
.
ENTERED
&&
_converse
.
auto_register_muc_nickname
&&
!
this
.
get
(
'
reserved_nick
'
))
{
!
this
.
get
(
'
reserved_nick
'
)
&&
await
_converse
.
api
.
disco
.
supports
(
Strophe
.
NS
.
MUC_REGISTER
,
this
.
get
(
'
jid
'
)))
{
if
(
await
_converse
.
api
.
disco
.
supports
(
Strophe
.
NS
.
MUC_REGISTER
,
this
.
get
(
'
jid
'
)))
{
this
.
registerNickname
()
}
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