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
da1f1035
Commit
da1f1035
authored
Jan 09, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bugfix. Don't include .chat-events, to avoid null reference
parent
2c7a942f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
15 deletions
+53
-15
spec/chatbox.js
spec/chatbox.js
+39
-11
src/converse-chatview.js
src/converse-chatview.js
+14
-4
No files found.
spec/chatbox.js
View file @
da1f1035
...
...
@@ -643,7 +643,7 @@
.
then
(
function
()
{
expect
(
_converse
.
api
.
vcard
.
get
).
toHaveBeenCalled
();
return
test_utils
.
waitUntil
(
function
()
{
return
chatbox
.
get
(
'
fullname
'
)
===
mock
.
cur_names
[
0
];
return
chatbox
.
get
(
'
fullname
'
)
===
mock
.
cur_names
[
0
];
},
100
);
}).
then
(
function
()
{
done
();
...
...
@@ -972,7 +972,7 @@
'
to
'
:
_converse
.
bare_jid
,
'
from
'
:
sender_jid
,
'
type
'
:
'
chat
'
})
.
c
(
'
body
'
).
t
(
"
message
from today
"
)
.
c
(
'
body
'
).
t
(
"
message
"
)
.
tree
();
_converse
.
chatboxes
.
onMessage
(
msg
);
...
...
@@ -996,7 +996,7 @@
'
to
'
:
_converse
.
bare_jid
,
'
from
'
:
sender_jid
,
'
type
'
:
'
chat
'
})
.
c
(
'
body
'
).
t
(
"
Inbetween message
"
)
.
c
(
'
body
'
).
t
(
"
Inbetween message
"
)
.
up
()
.
tree
();
_converse
.
chatboxes
.
onMessage
(
msg
);
...
...
@@ -1020,7 +1020,7 @@
'
to
'
:
_converse
.
bare_jid
,
'
from
'
:
sender_jid
,
'
type
'
:
'
chat
'
})
.
c
(
'
body
'
).
t
(
"
An earlier message
to
day
"
)
.
c
(
'
body
'
).
t
(
"
An earlier message
on the next
day
"
)
.
tree
();
_converse
.
chatboxes
.
onMessage
(
msg
);
...
...
@@ -1032,16 +1032,40 @@
'
to
'
:
_converse
.
bare_jid
,
'
from
'
:
sender_jid
,
'
type
'
:
'
chat
'
})
.
c
(
'
body
'
).
t
(
"
newer message from t
o
day
"
)
.
c
(
'
body
'
).
t
(
"
newer message from t
he next
day
"
)
.
tree
();
_converse
.
chatboxes
.
onMessage
(
msg
);
// Insert <composing> message, to also check that
// text messages are inserted correctly with
// temporary chat events in the chat contents.
msg
=
$msg
({
'
id
'
:
'
aeb219
'
,
'
to
'
:
_converse
.
bare_jid
,
'
xmlns
'
:
'
jabber:client
'
,
'
from
'
:
sender_jid
,
'
type
'
:
'
chat
'
})
.
c
(
'
composing
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
CHATSTATES
}).
up
()
.
tree
();
_converse
.
chatboxes
.
onMessage
(
msg
);
msg
=
$msg
({
'
id
'
:
'
aeb220
'
,
'
to
'
:
_converse
.
bare_jid
,
'
xmlns
'
:
'
jabber:client
'
,
'
from
'
:
sender_jid
,
'
type
'
:
'
chat
'
})
.
c
(
'
composing
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
CHATSTATES
}).
up
()
.
c
(
'
body
'
).
t
(
"
latest message
"
)
.
tree
();
_converse
.
chatboxes
.
onMessage
(
msg
);
var
chatboxview
=
_converse
.
chatboxviews
.
get
(
sender_jid
);
var
$chat_content
=
$
(
chatboxview
.
el
).
find
(
'
.chat-content
'
);
chatboxview
.
clearSpinner
();
//cleanup
var
$time
=
$chat_content
.
find
(
'
time
'
);
expect
(
$time
.
length
).
toEqual
(
3
);
expect
(
$time
.
length
).
toEqual
(
4
);
$time
=
$chat_content
.
find
(
'
time:first
'
);
expect
(
$time
.
data
(
'
isodate
'
)).
toEqual
(
'
2017-12-31T00:00:00+00:00
'
);
...
...
@@ -1058,15 +1082,19 @@
$el
=
$chat_content
.
find
(
'
.chat-message:eq(2)
'
);
expect
(
$el
.
find
(
'
.chat-msg-content
'
).
text
()).
toEqual
(
'
another inbetween message
'
);
$time
=
$chat_content
.
find
(
'
time:
last
'
);
$time
=
$chat_content
.
find
(
'
time:
nth(2)
'
);
expect
(
$time
.
data
(
'
isodate
'
)).
toEqual
(
'
2018-01-02T00:00:00+00:00
'
);
expect
(
$time
[
0
].
nextElementSibling
.
querySelector
(
'
.chat-msg-content
'
).
textContent
).
toBe
(
'
An earlier message
to
day
'
);
expect
(
$time
[
0
].
nextElementSibling
.
querySelector
(
'
.chat-msg-content
'
).
textContent
).
toBe
(
'
An earlier message
on the next
day
'
);
$el
=
$chat_content
.
find
(
'
.chat-message:eq(3)
'
);
expect
(
$el
.
find
(
'
.chat-msg-content
'
).
text
()).
toEqual
(
'
An earlier message
to
day
'
);
expect
(
$el
.
find
(
'
.chat-msg-content
'
).
text
()).
toEqual
(
'
An earlier message
on the next
day
'
);
$el
=
$chat_content
.
find
(
'
.chat-message:eq(4)
'
);
expect
(
$el
.
find
(
'
.chat-msg-content
'
).
text
()).
toEqual
(
'
message from today
'
);
expect
(
$el
[
0
].
nextElementSibling
.
querySelector
(
'
.chat-msg-content
'
).
textContent
).
toEqual
(
'
newer message from today
'
);
expect
(
$el
.
find
(
'
.chat-msg-content
'
).
text
()).
toEqual
(
'
message
'
);
expect
(
$el
[
0
].
nextElementSibling
.
querySelector
(
'
.chat-msg-content
'
).
textContent
).
toEqual
(
'
newer message from the next day
'
);
$time
=
$chat_content
.
find
(
'
time:last
'
);
expect
(
$time
.
data
(
'
isodate
'
)).
toEqual
(
moment
().
startOf
(
'
day
'
).
format
());
expect
(
$time
[
0
].
nextElementSibling
.
querySelector
(
'
.chat-msg-content
'
).
textContent
).
toBe
(
'
latest message
'
);
done
();
});
}));
...
...
src/converse-chatview.js
View file @
da1f1035
...
...
@@ -468,8 +468,14 @@
if
(
_
.
isNull
(
most_recent_date
)
||
moment
(
most_recent_date
).
isBefore
(
cutoff
))
{
return
most_recent_date
;
}
/* XXX: Besides .chat-message and .chat-date elements, there are also
* .chat-event elements. These are however temporary and
* removed once a new element is inserted into the chat
* area, so we don't query for them here, otherwise we get
* a null reference later upon element insertion.
*/
const
msg_dates
=
_
.
invokeMap
(
sizzle
(
'
.
message, .chat-info
'
,
this
.
content
),
sizzle
(
'
.
chat-message, .chat-date
'
,
this
.
content
),
Element
.
prototype
.
getAttribute
,
'
data-isodate
'
)
if
(
_
.
isObject
(
cutoff
))
{
...
...
@@ -621,6 +627,7 @@
}
else
if
(
message
.
get
(
'
chat_state
'
)
===
_converse
.
GONE
)
{
this
.
showStatusNotification
(
message
.
get
(
'
fullname
'
)
+
'
'
+
__
(
'
has gone away
'
));
}
return
message
;
},
shouldShowOnTextMessage
()
{
...
...
@@ -674,10 +681,13 @@
}
if
(
message
.
get
(
'
type
'
)
===
'
error
'
)
{
this
.
handleErrorMessage
(
message
);
}
else
if
(
!
message
.
get
(
'
message
'
))
{
this
.
handleChatStateMessage
(
message
);
}
else
{
this
.
handleTextMessage
(
message
);
if
(
message
.
get
(
'
chat_state
'
))
{
this
.
handleChatStateMessage
(
message
);
}
if
(
message
.
get
(
'
message
'
))
{
this
.
handleTextMessage
(
message
);
}
}
_converse
.
emit
(
'
messageAdded
'
,
{
'
message
'
:
message
,
...
...
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