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
a6aaf3f5
Commit
a6aaf3f5
authored
Feb 26, 2020
by
Lance Stout
Committed by
JC Brand
Mar 03, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update chat state notifications when message is edited.
parent
f34cc63d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
86 additions
and
2 deletions
+86
-2
CHANGES.md
CHANGES.md
+1
-0
spec/chatbox.js
spec/chatbox.js
+62
-0
src/converse-chatview.js
src/converse-chatview.js
+22
-2
src/converse-muc-views.js
src/converse-muc-views.js
+1
-0
No files found.
CHANGES.md
View file @
a6aaf3f5
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
-
#1313: Stylistic improvements to the send button
-
#1313: Stylistic improvements to the send button
-
#1535: Add option to destroy a MUC
-
#1535: Add option to destroy a MUC
-
#1715: Update chat state notification after receiving a message correction.
-
#1793: Send button doesn't appear in Firefox in 1:1 chats
-
#1793: Send button doesn't appear in Firefox in 1:1 chats
-
#1820: Set focus on jid field after controlbox is loaded
-
#1820: Set focus on jid field after controlbox is loaded
-
#1822: Don't log error if user has no bookmarks
-
#1822: Don't log error if user has no bookmarks
...
...
spec/chatbox.js
View file @
a6aaf3f5
...
@@ -1057,6 +1057,68 @@
...
@@ -1057,6 +1057,68 @@
done
();
done
();
}));
}));
});
});
describe
(
"
On receiving a message correction
"
,
function
()
{
it
(
"
will be updated
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
openControlBox
(
_converse
);
// See XEP-0085 https://xmpp.org/extensions/xep-0085.html#definitions
const
sender_jid
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@montague.lit
'
;
await
u
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
);
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
// Original message
const
original_id
=
u
.
getUniqueId
();
const
original
=
$msg
({
from
:
sender_jid
,
to
:
_converse
.
connection
.
jid
,
type
:
'
chat
'
,
id
:
original_id
,
body
:
"
Original message
"
,
}).
c
(
'
active
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
CHATSTATES
}).
tree
();
spyOn
(
_converse
.
api
,
"
trigger
"
).
and
.
callThrough
();
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
original
));
await
u
.
waitUntil
(()
=>
_converse
.
api
.
trigger
.
calls
.
count
());
expect
(
_converse
.
api
.
trigger
).
toHaveBeenCalledWith
(
'
message
'
,
jasmine
.
any
(
Object
));
const
view
=
_converse
.
chatboxviews
.
get
(
sender_jid
);
expect
(
view
).
toBeDefined
();
// <composing> state
const
msg
=
$msg
({
from
:
sender_jid
,
to
:
_converse
.
connection
.
jid
,
type
:
'
chat
'
,
id
:
u
.
getUniqueId
()
}).
c
(
'
composing
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
CHATSTATES
}).
tree
();
await
_converse
.
handleMessageStanza
(
msg
);
const
event
=
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.chat-state-notification
'
));
expect
(
event
.
textContent
).
toEqual
(
mock
.
cur_names
[
1
]
+
'
is typing
'
);
// Edited message
const
edited
=
$msg
({
from
:
sender_jid
,
to
:
_converse
.
connection
.
jid
,
type
:
'
chat
'
,
id
:
u
.
getUniqueId
(),
body
:
"
Edited message
"
,
})
.
c
(
'
active
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
CHATSTATES
}).
up
()
.
c
(
'
replace
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
MESSAGE_CORRECT
,
'
id
'
:
original_id
}).
tree
();
await
_converse
.
handleMessageStanza
(
edited
);
const
events
=
view
.
el
.
querySelectorAll
(
'
.chat-state-notification
'
);
expect
(
events
.
length
).
toBe
(
0
);
done
();
}));
});
});
});
});
});
...
...
src/converse-chatview.js
View file @
a6aaf3f5
...
@@ -196,6 +196,7 @@ converse.plugins.add('converse-chatview', {
...
@@ -196,6 +196,7 @@ converse.plugins.add('converse-chatview', {
this
.
initDebounced
();
this
.
initDebounced
();
this
.
listenTo
(
this
.
model
.
messages
,
'
add
'
,
this
.
onMessageAdded
);
this
.
listenTo
(
this
.
model
.
messages
,
'
add
'
,
this
.
onMessageAdded
);
this
.
listenTo
(
this
.
model
.
messages
,
'
change:edited
'
,
this
.
onMessageEdited
);
this
.
listenTo
(
this
.
model
.
messages
,
'
rendered
'
,
this
.
scrollDown
);
this
.
listenTo
(
this
.
model
.
messages
,
'
rendered
'
,
this
.
scrollDown
);
this
.
model
.
messages
.
on
(
'
reset
'
,
()
=>
{
this
.
model
.
messages
.
on
(
'
reset
'
,
()
=>
{
this
.
content
.
innerHTML
=
''
;
this
.
content
.
innerHTML
=
''
;
...
@@ -724,8 +725,7 @@ converse.plugins.add('converse-chatview', {
...
@@ -724,8 +725,7 @@ converse.plugins.add('converse-chatview', {
await
message
.
initialized
;
await
message
.
initialized
;
const
view
=
this
.
add
(
message
.
get
(
'
id
'
),
new
_converse
.
MessageView
({
'
model
'
:
message
}));
const
view
=
this
.
add
(
message
.
get
(
'
id
'
),
new
_converse
.
MessageView
({
'
model
'
:
message
}));
await
view
.
render
();
await
view
.
render
();
// Clear chat state notifications
this
.
clearChatStateForSender
(
message
.
get
(
'
from
'
));
sizzle
(
`.chat-state-notification[data-csn="
${
message
.
get
(
'
from
'
)}
"]`
,
this
.
content
).
forEach
(
u
.
removeElement
);
this
.
insertMessage
(
view
);
this
.
insertMessage
(
view
);
this
.
insertDayIndicator
(
view
.
el
);
this
.
insertDayIndicator
(
view
.
el
);
this
.
setScrollPosition
(
view
.
el
);
this
.
setScrollPosition
(
view
.
el
);
...
@@ -780,6 +780,16 @@ converse.plugins.add('converse-chatview', {
...
@@ -780,6 +780,16 @@ converse.plugins.add('converse-chatview', {
});
});
},
},
/**
* Handler that gets called when a message object has been edited via LMC.
* @private
* @method _converse.ChatBoxView#onMessageEdited
* @param { object } message - The updated message object.
*/
onMessageEdited
(
message
)
{
this
.
clearChatStateForSender
(
message
.
get
(
'
from
'
));
},
parseMessageForCommands
(
text
)
{
parseMessageForCommands
(
text
)
{
const
match
=
text
.
replace
(
/^
\s
*/
,
""
).
match
(
/^
\/(
.*
)\s
*$/
);
const
match
=
text
.
replace
(
/^
\s
*/
,
""
).
match
(
/^
\/(
.*
)\s
*$/
);
if
(
match
)
{
if
(
match
)
{
...
@@ -1072,6 +1082,16 @@ converse.plugins.add('converse-chatview', {
...
@@ -1072,6 +1082,16 @@ converse.plugins.add('converse-chatview', {
return
this
;
return
this
;
},
},
/**
* Remove chat state notifications for a given sender JID.
* @private
* @method _converse.ChatBoxView#clearChatStateForSender
* @param {string} sender - The sender of the chat state
*/
clearChatStateForSender
(
sender
)
{
sizzle
(
`.chat-state-notification[data-csn="
${
sender
}
"]`
,
this
.
content
).
forEach
(
u
.
removeElement
);
},
/**
/**
* Insert a particular string value into the textarea of this chat box.
* Insert a particular string value into the textarea of this chat box.
* @private
* @private
...
...
src/converse-muc-views.js
View file @
a6aaf3f5
...
@@ -700,6 +700,7 @@ converse.plugins.add('converse-muc-views', {
...
@@ -700,6 +700,7 @@ converse.plugins.add('converse-muc-views', {
this
.
initDebounced
();
this
.
initDebounced
();
this
.
listenTo
(
this
.
model
.
messages
,
'
add
'
,
this
.
onMessageAdded
);
this
.
listenTo
(
this
.
model
.
messages
,
'
add
'
,
this
.
onMessageAdded
);
this
.
listenTo
(
this
.
model
.
messages
,
'
change:edited
'
,
this
.
onMessageEdited
);
this
.
listenTo
(
this
.
model
.
messages
,
'
rendered
'
,
this
.
scrollDown
);
this
.
listenTo
(
this
.
model
.
messages
,
'
rendered
'
,
this
.
scrollDown
);
this
.
model
.
messages
.
on
(
'
reset
'
,
()
=>
{
this
.
model
.
messages
.
on
(
'
reset
'
,
()
=>
{
this
.
content
.
innerHTML
=
''
;
this
.
content
.
innerHTML
=
''
;
...
...
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