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
bc4d0165
Commit
bc4d0165
authored
Apr 08, 2020
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't show duplicate topic change notifications
parent
c4ba6735
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
10 deletions
+35
-10
spec/muc.js
spec/muc.js
+24
-4
src/headless/converse-muc.js
src/headless/converse-muc.js
+11
-6
No files found.
spec/muc.js
View file @
bc4d0165
...
...
@@ -608,19 +608,39 @@
</message>`
)));
await
u
.
waitUntil
(()
=>
view
.
model
.
handleSubjectChange
.
calls
.
count
()
===
2
);
cons
t
el
=
sizzle
(
'
.chat-info__message
'
,
view
.
el
).
pop
();
le
t
el
=
sizzle
(
'
.chat-info__message
'
,
view
.
el
).
pop
();
expect
(
el
.
textContent
.
trim
()).
toBe
(
'
Topic set by ralphm
'
);
await
u
.
waitUntil
(()
=>
desc
.
textContent
.
trim
()
===
'
This is a new topic
'
);
// Doesn't show multiple subsequent topic change notifications
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
u
.
toStanza
(
`
<message xmlns="jabber:client" to="
${
_converse
.
jid
}
" type="groupchat" from="jdev@conference.jabber.org/ralphm">
<subject>Yet another topic</subject>
</message>`
)));
await
u
.
waitUntil
(()
=>
view
.
model
.
handleSubjectChange
.
calls
.
count
()
===
3
);
await
u
.
waitUntil
(()
=>
desc
.
textContent
.
trim
()
===
'
Yet another topic
'
);
expect
(
sizzle
(
'
.chat-info__message
'
,
view
.
el
).
length
).
toBe
(
1
);
// Sow multiple subsequent topic change notification from someone else
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
u
.
toStanza
(
`
<message xmlns="jabber:client" to="
${
_converse
.
jid
}
" type="groupchat" from="jdev@conference.jabber.org/some1">
<subject>Some1's topic</subject>
</message>`
)));
await
u
.
waitUntil
(()
=>
view
.
model
.
handleSubjectChange
.
calls
.
count
()
===
4
);
await
u
.
waitUntil
(()
=>
desc
.
textContent
.
trim
()
===
"
Some1's topic
"
);
expect
(
sizzle
(
'
.chat-info__message
'
,
view
.
el
).
length
).
toBe
(
2
);
el
=
sizzle
(
'
.chat-info__message
'
,
view
.
el
).
pop
();
expect
(
el
.
textContent
.
trim
()).
toBe
(
'
Topic set by some1
'
);
// Removes current topic
const
stanza
=
u
.
toStanza
(
`<message xmlns="jabber:client" to="
${
_converse
.
jid
}
" type="groupchat" from="jdev@conference.jabber.org/
ralphm
">
`<message xmlns="jabber:client" to="
${
_converse
.
jid
}
" type="groupchat" from="jdev@conference.jabber.org/
some1
">
<subject/>
</message>`
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
await
u
.
waitUntil
(()
=>
view
.
model
.
handleSubjectChange
.
calls
.
count
()
===
3
);
await
u
.
waitUntil
(()
=>
view
.
model
.
handleSubjectChange
.
calls
.
count
()
===
5
);
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.chat-head__desc
'
)
===
null
);
expect
(
view
.
el
.
querySelector
(
'
.chat-info:last-child
'
).
textContent
.
trim
()).
toBe
(
"
Topic cleared by
ralphm
"
);
expect
(
view
.
el
.
querySelector
(
'
.chat-info:last-child
'
).
textContent
.
trim
()).
toBe
(
"
Topic cleared by
some1
"
);
done
();
}));
});
...
...
src/headless/converse-muc.js
View file @
bc4d0165
...
...
@@ -1703,12 +1703,17 @@ converse.plugins.add('converse-muc', {
});
if
(
!
attrs
.
is_delayed
)
{
const
message
=
subject
?
__
(
'
Topic set by %1$s
'
,
author
)
:
__
(
'
Topic cleared by %1$s
'
,
author
);
const
data
=
{
message
,
'
nick
'
:
attrs
.
nick
,
'
type
'
:
'
info
'
};
this
.
createMessage
(
data
);
const
prev_msg
=
this
.
messages
.
last
();
if
(
prev_msg
?.
get
(
'
nick
'
)
!==
attrs
.
nick
||
prev_msg
?.
get
(
'
type
'
)
!==
'
info
'
||
prev_msg
?.
get
(
'
message
'
)
!==
message
)
{
this
.
createMessage
({
message
,
'
nick
'
:
attrs
.
nick
,
'
type
'
:
'
info
'
});
}
}
return
true
;
}
...
...
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