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
77a0a01e
Commit
77a0a01e
authored
Jun 25, 2020
by
Ariel Fuggini
Committed by
GitHub
Jun 25, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Makes message with errors non-editable (#2089)
* Makes message with errors non-editable
parent
346e5d89
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
5 deletions
+15
-5
spec/messages.js
spec/messages.js
+10
-0
spec/muc_messages.js
spec/muc_messages.js
+1
-0
spec/retractions.js
spec/retractions.js
+1
-1
src/headless/converse-chat.js
src/headless/converse-chat.js
+2
-4
src/headless/converse-muc.js
src/headless/converse-muc.js
+1
-0
No files found.
spec/messages.js
View file @
77a0a01e
...
@@ -1681,6 +1681,16 @@ describe("A Chat Message", function () {
...
@@ -1681,6 +1681,16 @@ describe("A Chat Message", function () {
await
u
.
waitUntil
(()
=>
view
.
model
.
messages
.
length
>
3
);
await
u
.
waitUntil
(()
=>
view
.
model
.
messages
.
length
>
3
);
await
new
Promise
(
resolve
=>
view
.
model
.
messages
.
once
(
'
rendered
'
,
resolve
));
await
new
Promise
(
resolve
=>
view
.
model
.
messages
.
once
(
'
rendered
'
,
resolve
));
expect
(
view
.
content
.
querySelectorAll
(
'
.chat-error
'
).
length
).
toEqual
(
1
);
expect
(
view
.
content
.
querySelectorAll
(
'
.chat-error
'
).
length
).
toEqual
(
1
);
// Ensure messages with error are not editable
document
.
querySelectorAll
(
'
.chat-msg__actions
'
).
forEach
(
elem
=>
{
expect
(
elem
.
querySelector
(
'
.chat-msg__action-edit
'
)).
toBe
(
null
)
})
view
.
model
.
messages
.
forEach
(
message
=>
{
const
isEditable
=
message
.
get
(
'
editable
'
);
isEditable
&&
expect
(
isEditable
).
toBe
(
false
);
})
done
();
done
();
}));
}));
...
...
spec/muc_messages.js
View file @
77a0a01e
...
@@ -48,6 +48,7 @@ describe("A Groupchat Message", function () {
...
@@ -48,6 +48,7 @@ describe("A Groupchat Message", function () {
expect
(
message
.
get
(
'
received
'
)).
toBeUndefined
();
expect
(
message
.
get
(
'
received
'
)).
toBeUndefined
();
expect
(
message
.
get
(
'
body
'
)).
toBe
(
'
hello world
'
);
expect
(
message
.
get
(
'
body
'
)).
toBe
(
'
hello world
'
);
expect
(
message
.
get
(
'
error_text
'
)).
toBe
(
err_msg_text
);
expect
(
message
.
get
(
'
error_text
'
)).
toBe
(
err_msg_text
);
expect
(
message
.
get
(
'
editable
'
)).
toBe
(
false
);
done
();
done
();
}));
}));
});
});
...
...
spec/retractions.js
View file @
77a0a01e
...
@@ -702,7 +702,7 @@ describe("Message Retractions", function () {
...
@@ -702,7 +702,7 @@ describe("Message Retractions", function () {
expect
(
view
.
model
.
messages
.
length
).
toBe
(
1
);
expect
(
view
.
model
.
messages
.
length
).
toBe
(
1
);
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
retracted
'
)).
toBeFalsy
();
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
retracted
'
)).
toBeFalsy
();
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
is_ephemeral
'
)).
toBeFalsy
();
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
is_ephemeral
'
)).
toBeFalsy
();
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
editable
'
)).
toBe
Truthy
(
);
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
editable
'
)).
toBe
(
false
);
const
errmsg
=
view
.
el
.
querySelector
(
'
.chat-msg__error
'
);
const
errmsg
=
view
.
el
.
querySelector
(
'
.chat-msg__error
'
);
expect
(
errmsg
.
textContent
.
trim
()).
toBe
(
"
You're not allowed to retract your message.
"
);
expect
(
errmsg
.
textContent
.
trim
()).
toBe
(
"
You're not allowed to retract your message.
"
);
...
...
src/headless/converse-chat.js
View file @
77a0a01e
...
@@ -407,6 +407,7 @@ converse.plugins.add('converse-chat', {
...
@@ -407,6 +407,7 @@ converse.plugins.add('converse-chat', {
'
error_condition
'
:
attrs
.
error_condition
,
'
error_condition
'
:
attrs
.
error_condition
,
'
error_text
'
:
attrs
.
error_text
,
'
error_text
'
:
attrs
.
error_text
,
'
error_type
'
:
attrs
.
error_type
,
'
error_type
'
:
attrs
.
error_type
,
'
editable
'
:
false
,
};
};
if
(
attrs
.
msgid
===
message
.
get
(
'
retraction_id
'
))
{
if
(
attrs
.
msgid
===
message
.
get
(
'
retraction_id
'
))
{
// The error message refers to a retraction
// The error message refers to a retraction
...
@@ -979,10 +980,7 @@ converse.plugins.add('converse-chat', {
...
@@ -979,10 +980,7 @@ converse.plugins.add('converse-chat', {
* @param { String } send_time - time when the message was sent
* @param { String } send_time - time when the message was sent
*/
*/
setEditable
(
attrs
,
send_time
)
{
setEditable
(
attrs
,
send_time
)
{
if
(
attrs
.
is_headline
)
{
if
(
attrs
.
is_headline
||
u
.
isEmptyMessage
(
attrs
)
||
attrs
.
sender
!==
'
me
'
)
{
return
;
}
if
(
u
.
isEmptyMessage
(
attrs
)
||
attrs
.
sender
!==
'
me
'
)
{
return
;
return
;
}
}
if
(
api
.
settings
.
get
(
'
allow_message_corrections
'
)
===
'
all
'
)
{
if
(
api
.
settings
.
get
(
'
allow_message_corrections
'
)
===
'
all
'
)
{
...
...
src/headless/converse-muc.js
View file @
77a0a01e
...
@@ -631,6 +631,7 @@ converse.plugins.add('converse-muc', {
...
@@ -631,6 +631,7 @@ converse.plugins.add('converse-muc', {
'
error_condition
'
:
attrs
.
error_condition
,
'
error_condition
'
:
attrs
.
error_condition
,
'
error_text
'
:
attrs
.
error_text
,
'
error_text
'
:
attrs
.
error_text
,
'
error_type
'
:
attrs
.
error_type
,
'
error_type
'
:
attrs
.
error_type
,
'
editable
'
:
false
,
};
};
if
(
attrs
.
msgid
===
message
.
get
(
'
retraction_id
'
))
{
if
(
attrs
.
msgid
===
message
.
get
(
'
retraction_id
'
))
{
// The error message refers to a retraction
// The error message refers to a retraction
...
...
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