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
9750dcf3
Commit
9750dcf3
authored
Jun 19, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #1142. Show confirmation dialog for editing messages
when the textarea contains an unsent message
parent
1dc73c1c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
1 deletion
+31
-1
spec/messages.js
spec/messages.js
+21
-0
src/converse-chatview.js
src/converse-chatview.js
+9
-0
src/converse-modal.js
src/converse-modal.js
+1
-1
No files found.
spec/messages.js
View file @
9750dcf3
...
...
@@ -114,7 +114,28 @@
}).
c
(
'
body
'
).
t
(
'
Hello
'
).
up
()
.
c
(
'
active
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/chatstates
'
}).
tree
()
);
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg .chat-msg__action
'
).
length
).
toBe
(
1
);
// Test confirmation dialog
spyOn
(
window
,
'
confirm
'
).
and
.
returnValue
(
true
);
textarea
.
value
=
'
But soft, what light through yonder airlock breaks?
'
;
action
=
view
.
el
.
querySelector
(
'
.chat-msg .chat-msg__action
'
);
action
.
style
.
opacity
=
1
;
action
.
click
();
expect
(
window
.
confirm
).
toHaveBeenCalledWith
(
'
You have an unsent message which will be lost if you continue. Are you sure?
'
);
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
correcting
'
)).
toBe
(
true
);
expect
(
textarea
.
value
).
toBe
(
'
But soft, what light through yonder window breaks?
'
);
textarea
.
value
=
'
But soft, what light through yonder airlock breaks?
'
action
.
click
();
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
correcting
'
)).
toBe
(
false
);
expect
(
window
.
confirm
.
calls
.
count
()).
toBe
(
2
);
expect
(
window
.
confirm
.
calls
.
argsFor
(
0
)).
toEqual
(
[
'
You have an unsent message which will be lost if you continue. Are you sure?
'
]);
expect
(
window
.
confirm
.
calls
.
argsFor
(
1
)).
toEqual
(
[
'
You have an unsent message which will be lost if you continue. Are you sure?
'
]);
done
();
}));
...
...
src/converse-chatview.js
View file @
9750dcf3
...
...
@@ -1022,11 +1022,20 @@ converse.plugins.add('converse-chatview', {
onMessageEditButtonClicked
(
ev
)
{
ev
.
preventDefault
();
const
idx
=
this
.
model
.
messages
.
findLastIndex
(
'
correcting
'
),
currently_correcting
=
idx
>=
0
?
this
.
model
.
messages
.
at
(
idx
)
:
null
,
message_el
=
u
.
ancestor
(
ev
.
target
,
'
.chat-msg
'
),
message
=
this
.
model
.
messages
.
findWhere
({
'
msgid
'
:
message_el
.
getAttribute
(
'
data-msgid
'
)});
const
textarea
=
this
.
el
.
querySelector
(
'
.chat-textarea
'
);
if
(
textarea
.
value
&&
(
currently_correcting
===
null
||
currently_correcting
.
get
(
'
message
'
)
!==
textarea
.
value
))
{
if
(
!
confirm
(
__
(
"
You have an unsent message which will be lost if you continue. Are you sure?
"
)))
{
return
;
}
}
if
(
currently_correcting
!==
message
)
{
if
(
!
_
.
isNil
(
currently_correcting
))
{
currently_correcting
.
save
(
'
correcting
'
,
false
);
...
...
src/converse-modal.js
View file @
9750dcf3
...
...
@@ -73,7 +73,7 @@ converse.plugins.add('converse-modal', {
/************************ BEGIN API ************************/
// We extend the default converse.js API to add methods specific to MUC chat rooms.
let
alert
let
alert
;
Object
.
assign
(
_converse
.
api
,
{
'
alert
'
:
{
...
...
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