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
e305cc35
Commit
e305cc35
authored
Sep 10, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove `--larger` class on a edited message that's no longer just emojis
parent
54c90e14
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
5 deletions
+36
-5
spec/emojis.js
spec/emojis.js
+34
-4
src/headless/converse-chatboxes.js
src/headless/converse-chatboxes.js
+2
-1
No files found.
spec/emojis.js
View file @
e305cc35
...
...
@@ -159,9 +159,9 @@
});
describe
(
"
A Chat Message
"
,
function
()
{
it
(
"
will display larger if it's
a single emoji
"
,
it
(
"
will display larger if it's
only emojis
"
,
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
,
'
emojisInitialized
'
],
{
'
use_system_emojis
'
:
fals
e
},
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
,
'
emojisInitialized
'
],
{
'
use_system_emojis
'
:
tru
e
},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
...
...
@@ -176,7 +176,6 @@
await
new
Promise
(
resolve
=>
_converse
.
on
(
'
chatBoxInitialized
'
,
resolve
));
const
view
=
_converse
.
api
.
chatviews
.
get
(
sender_jid
);
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
const
chat_content
=
view
.
el
.
querySelector
(
'
.chat-content
'
);
let
message
=
chat_content
.
querySelector
(
'
.chat-msg__text
'
);
expect
(
u
.
hasClass
(
'
chat-msg__text--larger
'
,
message
)).
toBe
(
true
);
...
...
@@ -191,7 +190,38 @@
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
message
=
chat_content
.
querySelector
(
'
.message:last-child .chat-msg__text
'
);
expect
(
u
.
hasClass
(
'
chat-msg__text--larger
'
,
message
)).
toBe
(
false
);
done
();
// Test that a modified message that no longer contains only
// emojis now renders normally again.
const
textarea
=
view
.
el
.
querySelector
(
'
textarea.chat-textarea
'
);
textarea
.
value
=
'
:poop: :innocent:
'
;
view
.
onKeyDown
({
target
:
textarea
,
preventDefault
:
function
preventDefault
()
{},
keyCode
:
13
// Enter
});
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg
'
).
length
).
toBe
(
3
);
expect
(
chat_content
.
querySelector
(
'
.message:last-child .chat-msg__text
'
).
textContent
).
toBe
(
'
💩 😇
'
);
expect
(
textarea
.
value
).
toBe
(
''
);
view
.
onKeyDown
({
target
:
textarea
,
keyCode
:
38
// Up arrow
});
expect
(
textarea
.
value
).
toBe
(
'
💩 😇
'
);
expect
(
view
.
model
.
messages
.
at
(
2
).
get
(
'
correcting
'
)).
toBe
(
true
);
await
u
.
waitUntil
(()
=>
u
.
hasClass
(
'
correcting
'
,
view
.
el
.
querySelector
(
'
.chat-msg:last-child
'
)),
500
);
textarea
.
value
=
textarea
.
value
+=
'
This is no longer an emoji-only message
'
;
view
.
onKeyDown
({
target
:
textarea
,
preventDefault
:
function
preventDefault
()
{},
keyCode
:
13
// Enter
});
await
new
Promise
((
resolve
,
reject
)
=>
view
.
model
.
messages
.
once
(
'
rendered
'
,
resolve
));
expect
(
view
.
model
.
messages
.
models
.
length
).
toBe
(
3
);
message
=
chat_content
.
querySelector
(
'
.message:last-child .chat-msg__text
'
);
expect
(
u
.
hasClass
(
'
chat-msg__text--larger
'
,
message
)).
toBe
(
false
);
done
()
}));
});
});
...
...
src/headless/converse-chatboxes.js
View file @
e305cc35
...
...
@@ -558,7 +558,7 @@ converse.plugins.add('converse-chatboxes', {
}
const
older_versions
=
message
.
get
(
'
older_versions
'
)
||
{};
if
((
attrs
.
time
<
message
.
get
(
'
time
'
))
&&
message
.
get
(
'
edited
'
))
{
// This is an older message which has been corrected a
lready
// This is an older message which has been corrected a
fterwards
older_versions
[
attrs
.
time
]
=
attrs
[
'
message
'
];
message
.
save
({
'
older_versions
'
:
older_versions
});
}
else
{
...
...
@@ -787,6 +787,7 @@ converse.plugins.add('converse-chatboxes', {
'
message
'
:
attrs
.
message
,
'
older_versions
'
:
older_versions
,
'
references
'
:
attrs
.
references
,
'
is_single_emoji
'
:
attrs
.
message
?
u
.
isSingleEmoji
(
attrs
.
message
)
:
false
,
'
origin_id
'
:
_converse
.
connection
.
getUniqueId
(),
'
received
'
:
undefined
});
...
...
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