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
2cbc4aaa
Commit
2cbc4aaa
authored
Jun 26, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #1494. Trim whitespace around messages
parent
83bc851f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
2 deletions
+55
-2
CHANGES.md
CHANGES.md
+1
-0
spec/messages.js
spec/messages.js
+49
-0
src/converse-chatview.js
src/converse-chatview.js
+1
-1
src/headless/converse-chatboxes.js
src/headless/converse-chatboxes.js
+4
-1
No files found.
CHANGES.md
View file @
2cbc4aaa
...
...
@@ -37,6 +37,7 @@
-
#1445: Participants list uses big font in embedded mode
-
#1455: Avatar in controlbox status-view not updated
-
#1465: When highlighting a roster contact, they're incorrectly shown as online
-
#1494: Trim whitespace around messages
-
#1495: Mentions should always include a URI attribute
-
#1502: Fatal error when using prebind
-
#1532: Converse reloads on enter pressed in the filter box
...
...
spec/messages.js
View file @
2cbc4aaa
...
...
@@ -1396,6 +1396,26 @@
done
();
}));
describe
(
"
when sent
"
,
function
()
{
it
(
"
will be trimmed of leading and trailing whitespace
"
,
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@montague.lit
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
message
=
'
\n
This message is sent from this chatbox
\n
\n
'
;
await
test_utils
.
sendMessage
(
view
,
message
);
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
message
'
)).
toEqual
(
message
.
trim
());
const
message_el
=
sizzle
(
'
.chat-content .chat-msg:last .chat-msg__text
'
,
view
.
el
).
pop
();
expect
(
message_el
.
textContent
).
toEqual
(
message
.
trim
());
done
();
}));
});
describe
(
"
when received from someone else
"
,
function
()
{
...
...
@@ -1445,6 +1465,35 @@
done
();
}));
it
(
"
will be trimmed of leading and trailing whitespace
"
,
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
,
false
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
,
300
);
const
message
=
'
\n\n
This is a received message
\n\n
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@montague.lit
'
;
_converse
.
chatboxes
.
onMessage
(
$msg
({
'
from
'
:
sender_jid
,
'
to
'
:
_converse
.
connection
.
jid
,
'
type
'
:
'
chat
'
,
'
id
'
:
(
new
Date
()).
getTime
()
}).
c
(
'
body
'
).
t
(
message
).
up
()
.
c
(
'
active
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/chatstates
'
}).
tree
()
);
await
test_utils
.
waitUntil
(()
=>
(
_converse
.
api
.
chats
.
get
().
length
===
2
));
const
view
=
_converse
.
api
.
chatviews
.
get
(
sender_jid
);
expect
(
view
.
model
.
messages
.
length
).
toEqual
(
1
);
const
msg_obj
=
view
.
model
.
messages
.
at
(
0
);
expect
(
msg_obj
.
get
(
'
message
'
)).
toEqual
(
message
.
trim
());
const
chat_content
=
view
.
el
.
querySelector
(
'
.chat-content
'
);
expect
(
chat_content
.
querySelector
(
'
.chat-msg .chat-msg__text
'
).
textContent
).
toEqual
(
message
.
trim
());
done
();
}));
it
(
"
can be replaced with a correction
"
,
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
...
...
src/converse-chatview.js
View file @
2cbc4aaa
...
...
@@ -914,7 +914,7 @@ converse.plugins.add('converse-chatview', {
async
onFormSubmitted
(
ev
)
{
ev
.
preventDefault
();
const
textarea
=
this
.
el
.
querySelector
(
'
.chat-textarea
'
);
const
message
=
textarea
.
value
;
const
message
=
textarea
.
value
.
trim
()
;
if
(
_converse
.
message_limit
&&
message
.
length
>
_converse
.
message_limit
)
{
return
;
}
...
...
src/headless/converse-chatboxes.js
View file @
2cbc4aaa
...
...
@@ -841,7 +841,10 @@ converse.plugins.add('converse-chatboxes', {
if
(
type
===
'
error
'
)
{
return
this
.
getErrorMessage
(
stanza
);
}
else
{
return
_
.
propertyOf
(
stanza
.
querySelector
(
'
body
'
))(
'
textContent
'
);
const
body
=
stanza
.
querySelector
(
'
body
'
);
if
(
body
)
{
return
body
.
textContent
.
trim
();
}
}
},
...
...
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