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
227b7033
Commit
227b7033
authored
Feb 18, 2020
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bugfix. Retracted messages shouldn't be editable.
parent
004d2b7f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
31 deletions
+59
-31
spec/retractions.js
spec/retractions.js
+11
-4
src/converse-chatview.js
src/converse-chatview.js
+1
-16
src/converse-muc-views.js
src/converse-muc-views.js
+1
-9
src/headless/converse-chat.js
src/headless/converse-chat.js
+17
-2
src/headless/converse-muc.js
src/headless/converse-muc.js
+29
-0
No files found.
spec/retractions.js
View file @
227b7033
...
...
@@ -285,6 +285,12 @@
view
.
model
.
sendMessage
(
'
hello world
'
);
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelectorAll
(
'
.chat-msg
'
).
length
===
1
);
const
message
=
view
.
model
.
messages
.
at
(
0
);
expect
(
view
.
model
.
messages
.
length
).
toBe
(
1
);
expect
(
message
.
get
(
'
retracted
'
)).
toBeFalsy
();
expect
(
message
.
get
(
'
editable
'
)).
toBeTruthy
();
const
retract_button
=
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.chat-msg__content .chat-msg__action-retract
'
));
retract_button
.
click
();
await
u
.
waitUntil
(()
=>
u
.
isVisible
(
document
.
querySelector
(
'
#converse-modals .modal
'
)));
...
...
@@ -304,9 +310,9 @@
`</apply-to>`
+
`</message>`
);
const
message
=
view
.
model
.
messages
.
at
(
0
);
expect
(
view
.
model
.
messages
.
length
).
toBe
(
1
);
expect
(
message
.
get
(
'
retracted
'
)).
toBeTruthy
();
expect
(
message
.
get
(
'
editable
'
)).
toBeFalsy
();
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg--retracted
'
).
length
).
toBe
(
1
);
const
el
=
view
.
el
.
querySelector
(
'
.chat-msg--retracted .chat-msg__message
'
);
expect
(
el
.
textContent
.
trim
()).
toBe
(
'
Romeo Montague has removed this message
'
);
...
...
@@ -565,7 +571,8 @@
const
message
=
view
.
model
.
messages
.
at
(
0
);
expect
(
message
.
get
(
'
retracted
'
)).
toBeTruthy
();
expect
(
message
.
get
(
'
is_ephemeral
'
)).
toBe
(
false
);
expect
(
message
.
get
(
'
is_ephemeral
'
)).
toBeTruthy
();
expect
(
message
.
get
(
'
editable
'
)).
toBeFalsy
();
const
stanza_id
=
message
.
get
(
`stanza_id
${
muc_jid
}
`
);
// The server responds with a retraction message
...
...
@@ -584,7 +591,8 @@
expect
(
view
.
model
.
messages
.
length
).
toBe
(
1
);
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
retracted
'
)).
toBeTruthy
();
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
is_ephemeral
'
)).
toBe
(
false
);
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
is_ephemeral
'
)).
toBe
(
true
);
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
editable
'
)).
toBe
(
false
);
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg--retracted
'
).
length
).
toBe
(
1
);
const
el
=
view
.
el
.
querySelector
(
'
.chat-msg--retracted .chat-msg__message div
'
);
expect
(
el
.
textContent
).
toBe
(
'
romeo has removed this message
'
);
...
...
@@ -628,7 +636,6 @@
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
error
));
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelectorAll
(
'
.chat-error
'
).
length
===
1
);
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelectorAll
(
'
.chat-msg--retracted
'
).
length
===
0
);
expect
(
view
.
model
.
messages
.
length
).
toBe
(
1
);
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
retracted
'
)).
toBeFalsy
();
...
...
src/converse-chatview.js
View file @
227b7033
...
...
@@ -960,21 +960,6 @@ converse.plugins.add('converse-chatview', {
this
.
insertIntoTextArea
(
''
,
true
,
false
);
},
/**
* Retract one of your messages in this chat
* @private
* @method _converse.ChatBoxView#retractOwnMessage
* @param { _converse.Message } message - The message which we're retracting.
*/
retractOwnMessage
(
message
)
{
this
.
model
.
sendRetractionMessage
(
message
);
message
.
save
({
'
retracted
'
:
(
new
Date
()).
toISOString
(),
'
retracted_id
'
:
message
.
get
(
'
origin_id
'
),
'
is_ephemeral
'
:
true
});
},
async
onMessageRetractButtonClicked
(
ev
)
{
ev
.
preventDefault
();
const
msg_el
=
u
.
ancestor
(
ev
.
target
,
'
.message
'
);
...
...
@@ -995,7 +980,7 @@ converse.plugins.add('converse-chatview', {
}
const
result
=
await
_converse
.
api
.
confirm
(
__
(
'
Confirm
'
),
messages
);
if
(
result
)
{
this
.
retractOwnMessage
(
message
);
this
.
model
.
retractOwnMessage
(
message
);
}
},
...
...
src/converse-muc-views.js
View file @
227b7033
...
...
@@ -969,12 +969,8 @@ converse.plugins.add('converse-muc-views', {
* @param { _converse.Message } message - The message which we're retracting.
*/
retractOwnMessage
(
message
)
{
this
.
model
.
sendRetractio
nMessage
(
message
)
this
.
model
.
retractOw
nMessage
(
message
)
.
catch
(
e
=>
{
message
.
save
({
'
retracted
'
:
undefined
,
'
retracted_id
'
:
undefined
});
const
errmsg
=
__
(
'
Sorry, something went wrong while trying to retract your message.
'
);
if
(
u
.
isErrorStanza
(
e
))
{
this
.
showErrorMessage
(
errmsg
);
...
...
@@ -984,10 +980,6 @@ converse.plugins.add('converse-muc-views', {
}
log
.
error
(
e
);
});
message
.
save
({
'
retracted
'
:
(
new
Date
()).
toISOString
(),
'
retracted_id
'
:
message
.
get
(
'
origin_id
'
)
});
},
/**
...
...
src/headless/converse-chat.js
View file @
227b7033
...
...
@@ -708,6 +708,22 @@ converse.plugins.add('converse-chat', {
}
},
/**
* Retract one of your messages in this chat
* @private
* @method _converse.ChatBoxView#retractOwnMessage
* @param { _converse.Message } message - The message which we're retracting.
*/
retractOwnMessage
(
message
)
{
this
.
sendRetractionMessage
(
message
)
message
.
save
({
'
retracted
'
:
(
new
Date
()).
toISOString
(),
'
retracted_id
'
:
message
.
get
(
'
origin_id
'
),
'
is_ephemeral
'
:
true
,
'
editable
'
:
false
});
},
/**
* Sends a message stanza to retract a message in this chat
* @private
...
...
@@ -899,8 +915,7 @@ converse.plugins.add('converse-chat', {
}
if
(
_converse
.
allow_message_corrections
===
'
all
'
)
{
attrs
.
editable
=
!
(
attrs
.
file
||
attrs
.
retracted
||
'
oob_url
'
in
attrs
);
}
else
if
((
_converse
.
allow_message_corrections
===
'
last
'
)
&&
(
send_time
>
this
.
get
(
'
time_sent
'
)))
{
}
else
if
((
_converse
.
allow_message_corrections
===
'
last
'
)
&&
(
send_time
>
this
.
get
(
'
time_sent
'
)))
{
this
.
set
({
'
time_sent
'
:
send_time
});
const
msg
=
this
.
messages
.
findWhere
({
'
editable
'
:
true
});
if
(
msg
)
{
...
...
src/headless/converse-muc.js
View file @
227b7033
...
...
@@ -647,6 +647,35 @@ converse.plugins.add('converse-muc', {
return
promise
;
},
/**
* Retract one of your messages in this chat
* @private
* @method _converse.ChatRoom#retractOwnMessage
* @param { _converse.Message } message - The message which we're retracting.
*/
async
retractOwnMessage
(
message
)
{
const
editable
=
message
.
get
(
'
editable
'
);
const
is_ephemeral
=
message
.
get
(
'
is_ephemeral
'
);
// Optimistic save
message
.
save
({
'
retracted
'
:
(
new
Date
()).
toISOString
(),
'
retracted_id
'
:
message
.
get
(
'
origin_id
'
),
'
is_ephemeral
'
:
true
,
'
editable
'
:
false
});
try
{
await
this
.
sendRetractionMessage
(
message
)
}
catch
(
e
)
{
message
.
save
({
is_ephemeral
,
editable
,
'
retracted
'
:
undefined
,
'
retracted_id
'
:
undefined
,
});
throw
e
;
}
},
/**
* Sends a message stanza to retract a message in this groupchat.
* @private
...
...
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