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
d77802da
Commit
d77802da
authored
Oct 13, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid showing notification messages twice
For example `This groupchat is not anonymous`
parent
f5686a50
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
99 additions
and
2 deletions
+99
-2
CHANGES.md
CHANGES.md
+1
-0
dist/converse.js
dist/converse.js
+19
-1
spec/chatroom.js
spec/chatroom.js
+61
-0
src/converse-muc-views.js
src/converse-muc-views.js
+18
-1
No files found.
CHANGES.md
View file @
d77802da
...
...
@@ -4,6 +4,7 @@
-
Bugfix. Handler not triggered when submitting MUC password form 2nd time
-
Bugfix. MUC features weren't being refreshed when saving the config form
-
Don't show duplicate notification messages
-
#537 Render
`xmpp:`
URI as link
-
#1062 Collapse multiple join/leave messages into one
-
#1063 URLs in the topic / subject are not clickable
...
...
dist/converse.js
View file @
d77802da
...
...
@@ -69899,6 +69899,24 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return;
},
getNotificationWithMessage(message) {
let el = this.content.lastElementChild;
while (!_.isNil(el)) {
const data = _.get(el, 'dataset', {});
if (!_.includes(_.get(el, 'classList', []), 'chat-info')) {
return;
}
if (el.textContent === message) {
return el;
}
el = el.previousElementSibling;
}
},
parseXUserElement(x, stanza, is_self) {
/* Parse the passed-in <x xmlns='http://jabber.org/protocol/muc#user'>
* element and construct a map containing relevant
...
...
@@ -69911,7 +69929,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
const notification = {};
const messages = _.reject(_.
map(statuses, mapper), _.isUndefined
);
const messages = _.reject(_.
reject(_.map(statuses, mapper), _.isUndefined), message => this.getNotificationWithMessage(message)
);
if (messages.length) {
notification.messages = messages;
spec/chatroom.js
View file @
d77802da
...
...
@@ -411,6 +411,67 @@
describe
(
"
A Groupchat
"
,
function
()
{
it
(
"
shows a notification if its not anonymous
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
openChatRoom
(
_converse
,
"
coven
"
,
'
chat.shakespeare.lit
'
,
'
some1
'
)
.
then
(()
=>
{
const
view
=
_converse
.
chatboxviews
.
get
(
'
coven@chat.shakespeare.lit
'
);
const
chat_content
=
view
.
el
.
querySelector
(
'
.chat-content
'
);
/* <presence to="dummy@localhost/_converse.js-29092160"
* from="coven@chat.shakespeare.lit/some1">
* <x xmlns="http://jabber.org/protocol/muc#user">
* <item affiliation="owner" jid="dummy@localhost/_converse.js-29092160" role="moderator"/>
* <status code="110"/>
* <status code="100"/>
* </x>
* </presence></body>
*/
let
presence
=
$pres
({
to
:
'
dummy@localhost/resource
'
,
from
:
'
coven@chat.shakespeare.lit/some1
'
}).
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
item
'
,
{
'
affiliation
'
:
'
owner
'
,
'
jid
'
:
'
dummy@localhost/_converse.js-29092160
'
,
'
role
'
:
'
moderator
'
}).
up
()
.
c
(
'
status
'
,
{
code
:
'
110
'
}).
up
()
.
c
(
'
status
'
,
{
code
:
'
100
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
expect
(
chat_content
.
querySelectorAll
(
'
.chat-info
'
).
length
).
toBe
(
2
);
expect
(
sizzle
(
'
div.chat-info:first
'
,
chat_content
).
pop
().
textContent
)
.
toBe
(
"
This groupchat is not anonymous
"
);
expect
(
sizzle
(
'
div.chat-info:last
'
,
chat_content
).
pop
().
textContent
)
.
toBe
(
"
some1 has entered the groupchat
"
);
// Check that we don't show the notification twice
presence
=
$pres
({
to
:
'
dummy@localhost/resource
'
,
from
:
'
coven@chat.shakespeare.lit/some1
'
}).
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
item
'
,
{
'
affiliation
'
:
'
owner
'
,
'
jid
'
:
'
dummy@localhost/_converse.js-29092160
'
,
'
role
'
:
'
moderator
'
}).
up
()
.
c
(
'
status
'
,
{
code
:
'
110
'
}).
up
()
.
c
(
'
status
'
,
{
code
:
'
100
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
expect
(
chat_content
.
querySelectorAll
(
'
.chat-info
'
).
length
).
toBe
(
2
);
expect
(
sizzle
(
'
div.chat-info:first
'
,
chat_content
).
pop
().
textContent
)
.
toBe
(
"
This groupchat is not anonymous
"
);
expect
(
sizzle
(
'
div.chat-info:last
'
,
chat_content
).
pop
().
textContent
)
.
toBe
(
"
some1 has entered the groupchat
"
);
done
();
}).
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
))
}));
it
(
"
shows join/leave messages when users enter or exit a groupchat
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
...
...
src/converse-muc-views.js
View file @
d77802da
...
...
@@ -1400,6 +1400,20 @@
return
;
},
getNotificationWithMessage
(
message
)
{
let
el
=
this
.
content
.
lastElementChild
;
while
(
!
_
.
isNil
(
el
))
{
const
data
=
_
.
get
(
el
,
'
dataset
'
,
{});
if
(
!
_
.
includes
(
_
.
get
(
el
,
'
classList
'
,
[]),
'
chat-info
'
))
{
return
;
}
if
(
el
.
textContent
===
message
)
{
return
el
;
}
el
=
el
.
previousElementSibling
;
}
},
parseXUserElement
(
x
,
stanza
,
is_self
)
{
/* Parse the passed-in <x xmlns='http://jabber.org/protocol/muc#user'>
* element and construct a map containing relevant
...
...
@@ -1409,7 +1423,10 @@
const
statuses
=
x
.
querySelectorAll
(
'
status
'
);
const
mapper
=
_
.
partial
(
this
.
getMessageFromStatus
,
_
,
stanza
,
is_self
);
const
notification
=
{};
const
messages
=
_
.
reject
(
_
.
map
(
statuses
,
mapper
),
_
.
isUndefined
);
const
messages
=
_
.
reject
(
_
.
reject
(
_
.
map
(
statuses
,
mapper
),
_
.
isUndefined
),
message
=>
this
.
getNotificationWithMessage
(
message
)
);
if
(
messages
.
length
)
{
notification
.
messages
=
messages
;
}
...
...
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