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
083f191e
Commit
083f191e
authored
Jun 07, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Consider delayed, non-archived messages as "new"
New in the sense that we haven't seen them before
parent
ec65bb35
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
29 deletions
+33
-29
dist/converse.js
dist/converse.js
+11
-10
spec/chatbox.js
spec/chatbox.js
+2
-2
spec/messages.js
spec/messages.js
+6
-6
src/converse-chatboxes.js
src/converse-chatboxes.js
+8
-7
src/converse-message-view.js
src/converse-message-view.js
+1
-1
src/utils/core.js
src/utils/core.js
+5
-3
No files found.
dist/converse.js
View file @
083f191e
...
...
@@ -62532,21 +62532,22 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* that contains the message stanza, if it was
* contained, otherwise it's the message stanza itself.
*/
delay = delay || message.querySelector('delay');
const _converse = this.__super__._converse,
__ = _converse.__,
spoiler = message.querySelector(`spoiler[xmlns="${Strophe.NS.SPOILER}"]`),
archive = sizzle(`result[xmlns="${Strophe.NS.MAM}"]`, original_stanza).pop(),
spoiler = sizzle(`spoiler[xmlns="${Strophe.NS.SPOILER}"]`, original_stanza).pop(),
delay = sizzle(`delay[xmlns="${Strophe.NS.DELAY}"]`, original_stanza).pop(),
chat_state = message.getElementsByTagName(_converse.COMPOSING).length && _converse.COMPOSING || message.getElementsByTagName(_converse.PAUSED).length && _converse.PAUSED || message.getElementsByTagName(_converse.INACTIVE).length && _converse.INACTIVE || message.getElementsByTagName(_converse.ACTIVE).length && _converse.ACTIVE || message.getElementsByTagName(_converse.GONE).length && _converse.GONE;
const attrs = {
'type': message.getAttribute('type'),
'chat_state': chat_state,
'delayed': !_.isNull(delay),
'is_archived': !_.isNil(archive),
'is_delayed': !_.isNil(delay),
'is_spoiler': !_.isNil(spoiler),
'message': this.getMessageBody(message) || undefined,
'msgid': message.getAttribute('id'),
'time': delay ? delay.getAttribute('stamp') : moment().format(),
'
is_spoiler': !_.isNull(spoiler
)
'
type': message.getAttribute('type'
)
};
if (attrs.type === 'groupchat') {
...
...
@@ -62589,7 +62590,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
const attrs = this.getMessageAttributesFromStanza(message, original_stanza);
const is_csn = u.isOnlyChatStateNotification(attrs);
if (is_csn && (attrs.delayed || attrs.type === 'groupchat' && Strophe.getResourceFromJid(attrs.from) == this.get('nick'))) {
if (is_csn && (attrs.
is_
delayed || attrs.type === 'groupchat' && Strophe.getResourceFromJid(attrs.from) == this.get('nick'))) {
// XXX: MUC leakage
// No need showing delayed or our own CSN messages
return;
...
...
@@ -68427,7 +68428,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
},
getExtraMessageClasses() {
let extra_classes = this.model.get('delayed') && 'delayed' || '';
let extra_classes = this.model.get('
is_
delayed') && 'delayed' || '';
if (this.model.get('type') === 'groupchat' && this.model.get('sender') === 'them') {
if (this.model.collection.chatbox.isUserMentioned(this.model.get('message'))) {
...
...
@@ -80775,9 +80776,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* message, i.e. not a MAM archived one.
*/
if (message instanceof Element) {
return !
sizzle('result[xmlns="' + Strophe.NS.MAM + '"]', message).length && !sizzle('delay[xmlns="' + Strophe.NS.DELAY + '"]', message).length
;
return !
(sizzle(`result[xmlns="${Strophe.NS.MAM}"]`, message).length && sizzle(`delay[xmlns="${Strophe.NS.DELAY}"]`, message).length)
;
} else {
return !
message.get('delayed'
);
return !
(message.get('is_delayed') && message.get('is_archived')
);
}
};
spec/chatbox.js
View file @
083f191e
...
...
@@ -745,7 +745,7 @@
expect
(
chatbox
.
messages
.
length
).
toEqual
(
1
);
var
msg_obj
=
chatbox
.
messages
.
models
[
0
];
expect
(
msg_obj
.
get
(
'
sender
'
)).
toEqual
(
'
me
'
);
expect
(
msg_obj
.
get
(
'
delayed
'
)).
toEqual
(
false
);
expect
(
msg_obj
.
get
(
'
is_
delayed
'
)).
toEqual
(
false
);
var
$chat_content
=
$
(
chatboxview
.
el
).
find
(
'
.chat-content
'
);
var
status_text
=
$chat_content
.
find
(
'
.chat-info.chat-state-notification
'
).
text
();
expect
(
status_text
).
toBe
(
'
Typing from another device
'
);
...
...
@@ -893,7 +893,7 @@
expect
(
chatbox
.
messages
.
length
).
toEqual
(
1
);
var
msg_obj
=
chatbox
.
messages
.
models
[
0
];
expect
(
msg_obj
.
get
(
'
sender
'
)).
toEqual
(
'
me
'
);
expect
(
msg_obj
.
get
(
'
delayed
'
)).
toEqual
(
false
);
expect
(
msg_obj
.
get
(
'
is_
delayed
'
)).
toEqual
(
false
);
var
$chat_content
=
$
(
chatboxview
.
el
).
find
(
'
.chat-content
'
);
var
status_text
=
$chat_content
.
find
(
'
.chat-info.chat-state-notification
'
).
text
();
expect
(
status_text
).
toBe
(
'
Stopped typing on the other device
'
);
...
...
spec/messages.js
View file @
083f191e
...
...
@@ -60,7 +60,7 @@
expect
(
msg_obj
.
get
(
'
message
'
)).
toEqual
(
message
);
expect
(
msg_obj
.
get
(
'
fullname
'
)).
toEqual
(
mock
.
cur_names
[
0
]);
expect
(
msg_obj
.
get
(
'
sender
'
)).
toEqual
(
'
them
'
);
expect
(
msg_obj
.
get
(
'
delayed
'
)).
toEqual
(
false
);
expect
(
msg_obj
.
get
(
'
is_
delayed
'
)).
toEqual
(
false
);
// Now check that the message appears inside the chatbox in the DOM
var
chat_content
=
chatboxview
.
el
.
querySelector
(
'
.chat-content
'
);
expect
(
chat_content
.
querySelector
(
'
.chat-msg .chat-msg-text
'
).
textContent
).
toEqual
(
message
);
...
...
@@ -176,7 +176,7 @@
expect
(
msg_obj
.
get
(
'
message
'
)).
toEqual
(
message
);
expect
(
msg_obj
.
get
(
'
fullname
'
)).
toEqual
(
undefined
);
expect
(
msg_obj
.
get
(
'
sender
'
)).
toEqual
(
'
them
'
);
expect
(
msg_obj
.
get
(
'
delayed
'
)).
toEqual
(
false
);
expect
(
msg_obj
.
get
(
'
is_
delayed
'
)).
toEqual
(
false
);
// Now check that the message appears inside the chatbox in the DOM
var
chat_content
=
chatboxview
.
el
.
querySelector
(
'
.chat-content
'
);
expect
(
chat_content
.
querySelector
(
'
.chat-msg .chat-msg-text
'
).
textContent
).
toEqual
(
message
);
...
...
@@ -690,7 +690,7 @@
expect
(
msg_obj
.
get
(
'
message
'
)).
toEqual
(
msgtext
);
expect
(
msg_obj
.
get
(
'
fullname
'
)).
toEqual
(
mock
.
cur_names
[
1
]);
expect
(
msg_obj
.
get
(
'
sender
'
)).
toEqual
(
'
them
'
);
expect
(
msg_obj
.
get
(
'
delayed
'
)).
toEqual
(
false
);
expect
(
msg_obj
.
get
(
'
is_
delayed
'
)).
toEqual
(
false
);
// Now check that the message appears inside the chatbox in the DOM
var
chat_content
=
chatboxview
.
el
.
querySelector
(
'
.chat-content
'
);
expect
(
chat_content
.
querySelector
(
'
.chat-msg .chat-msg-text
'
).
textContent
).
toEqual
(
msgtext
);
...
...
@@ -743,7 +743,7 @@
expect
(
msg_obj
.
get
(
'
message
'
)).
toEqual
(
msgtext
);
expect
(
msg_obj
.
get
(
'
fullname
'
)).
toEqual
(
_converse
.
xmppstatus
.
get
(
'
fullname
'
));
expect
(
msg_obj
.
get
(
'
sender
'
)).
toEqual
(
'
me
'
);
expect
(
msg_obj
.
get
(
'
delayed
'
)).
toEqual
(
false
);
expect
(
msg_obj
.
get
(
'
is_
delayed
'
)).
toEqual
(
false
);
// Now check that the message appears inside the chatbox in the DOM
var
$chat_content
=
$
(
chatboxview
.
el
).
find
(
'
.chat-content
'
);
var
msg_txt
=
$chat_content
.
find
(
'
.chat-msg
'
).
find
(
'
.chat-msg-text
'
).
text
();
...
...
@@ -899,7 +899,7 @@
expect
(
msg_obj
.
get
(
'
message
'
)).
toEqual
(
message
);
expect
(
msg_obj
.
get
(
'
fullname
'
)).
toEqual
(
contact_name
);
expect
(
msg_obj
.
get
(
'
sender
'
)).
toEqual
(
'
them
'
);
expect
(
msg_obj
.
get
(
'
delayed
'
)).
toEqual
(
true
);
expect
(
msg_obj
.
get
(
'
is_
delayed
'
)).
toEqual
(
true
);
return
test_utils
.
waitUntil
(()
=>
chatbox
.
vcard
.
get
(
'
fullname
'
)
===
'
Candice van der Knijff
'
)
.
then
(
function
()
{
...
...
@@ -945,7 +945,7 @@
expect
(
msg_obj
.
get
(
'
message
'
)).
toEqual
(
message
);
expect
(
msg_obj
.
get
(
'
fullname
'
)).
toEqual
(
contact_name
);
expect
(
msg_obj
.
get
(
'
sender
'
)).
toEqual
(
'
them
'
);
expect
(
msg_obj
.
get
(
'
delayed
'
)).
toEqual
(
false
);
expect
(
msg_obj
.
get
(
'
is_
delayed
'
)).
toEqual
(
false
);
msg_txt
=
$chat_content
.
find
(
'
.chat-msg
'
).
last
().
find
(
'
.chat-msg-text
'
).
text
();
expect
(
msg_txt
).
toEqual
(
message
);
...
...
src/converse-chatboxes.js
View file @
083f191e
...
...
@@ -439,11 +439,11 @@
* that contains the message stanza, if it was
* contained, otherwise it's the message stanza itself.
*/
delay
=
delay
||
message
.
querySelector
(
'
delay
'
);
const
{
_converse
}
=
this
.
__super__
,
{
__
}
=
_converse
,
spoiler
=
message
.
querySelector
(
`spoiler[xmlns="
${
Strophe
.
NS
.
SPOILER
}
"]`
),
archive
=
sizzle
(
`result[xmlns="
${
Strophe
.
NS
.
MAM
}
"]`
,
original_stanza
).
pop
(),
spoiler
=
sizzle
(
`spoiler[xmlns="
${
Strophe
.
NS
.
SPOILER
}
"]`
,
original_stanza
).
pop
(),
delay
=
sizzle
(
`delay[xmlns="
${
Strophe
.
NS
.
DELAY
}
"]`
,
original_stanza
).
pop
(),
chat_state
=
message
.
getElementsByTagName
(
_converse
.
COMPOSING
).
length
&&
_converse
.
COMPOSING
||
message
.
getElementsByTagName
(
_converse
.
PAUSED
).
length
&&
_converse
.
PAUSED
||
message
.
getElementsByTagName
(
_converse
.
INACTIVE
).
length
&&
_converse
.
INACTIVE
||
...
...
@@ -451,13 +451,14 @@
message
.
getElementsByTagName
(
_converse
.
GONE
).
length
&&
_converse
.
GONE
;
const
attrs
=
{
'
type
'
:
message
.
getAttribute
(
'
type
'
),
'
chat_state
'
:
chat_state
,
'
delayed
'
:
!
_
.
isNull
(
delay
),
'
is_archived
'
:
!
_
.
isNil
(
archive
),
'
is_delayed
'
:
!
_
.
isNil
(
delay
),
'
is_spoiler
'
:
!
_
.
isNil
(
spoiler
),
'
message
'
:
this
.
getMessageBody
(
message
)
||
undefined
,
'
msgid
'
:
message
.
getAttribute
(
'
id
'
),
'
time
'
:
delay
?
delay
.
getAttribute
(
'
stamp
'
)
:
moment
().
format
(),
'
is_spoiler
'
:
!
_
.
isNull
(
spoiler
)
'
type
'
:
message
.
getAttribute
(
'
type
'
)
};
if
(
attrs
.
type
===
'
groupchat
'
)
{
attrs
.
from
=
message
.
getAttribute
(
'
from
'
);
...
...
@@ -493,7 +494,7 @@
*/
const
attrs
=
this
.
getMessageAttributesFromStanza
(
message
,
original_stanza
);
const
is_csn
=
u
.
isOnlyChatStateNotification
(
attrs
);
if
(
is_csn
&&
(
attrs
.
delayed
||
(
attrs
.
type
===
'
groupchat
'
&&
Strophe
.
getResourceFromJid
(
attrs
.
from
)
==
this
.
get
(
'
nick
'
))))
{
if
(
is_csn
&&
(
attrs
.
is_
delayed
||
(
attrs
.
type
===
'
groupchat
'
&&
Strophe
.
getResourceFromJid
(
attrs
.
from
)
==
this
.
get
(
'
nick
'
))))
{
// XXX: MUC leakage
// No need showing delayed or our own CSN messages
return
;
...
...
src/converse-message-view.js
View file @
083f191e
...
...
@@ -225,7 +225,7 @@
},
getExtraMessageClasses
()
{
let
extra_classes
=
this
.
model
.
get
(
'
delayed
'
)
&&
'
delayed
'
||
''
;
let
extra_classes
=
this
.
model
.
get
(
'
is_
delayed
'
)
&&
'
delayed
'
||
''
;
if
(
this
.
model
.
get
(
'
type
'
)
===
'
groupchat
'
&&
this
.
model
.
get
(
'
sender
'
)
===
'
them
'
)
{
if
(
this
.
model
.
collection
.
chatbox
.
isUserMentioned
(
this
.
model
.
get
(
'
message
'
)))
{
// Add special class to mark groupchat messages
...
...
src/utils/core.js
View file @
083f191e
...
...
@@ -483,10 +483,12 @@
* message, i.e. not a MAM archived one.
*/
if
(
message
instanceof
Element
)
{
return
!
sizzle
(
'
result[xmlns="
'
+
Strophe
.
NS
.
MAM
+
'
"]
'
,
message
).
length
&&
!
sizzle
(
'
delay[xmlns="
'
+
Strophe
.
NS
.
DELAY
+
'
"]
'
,
message
).
length
;
return
!
(
sizzle
(
`result[xmlns="
${
Strophe
.
NS
.
MAM
}
"]`
,
message
).
length
&&
sizzle
(
`delay[xmlns="
${
Strophe
.
NS
.
DELAY
}
"]`
,
message
).
length
);
}
else
{
return
!
message
.
get
(
'
delayed
'
);
return
!
(
message
.
get
(
'
is_delayed
'
)
&&
message
.
get
(
'
is_archived
'
)
);
}
};
...
...
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