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
c83026e5
Commit
c83026e5
authored
May 24, 2017
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
muc: Differentiate between generally unread messages and unread mentions
parent
8fa06e7d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
38 deletions
+66
-38
spec/roomslist.js
spec/roomslist.js
+40
-30
src/converse-muc.js
src/converse-muc.js
+24
-7
src/converse-roomslist.js
src/converse-roomslist.js
+1
-0
src/templates/rooms_list_item.html
src/templates/rooms_list_item.html
+1
-1
No files found.
spec/roomslist.js
View file @
c83026e5
...
@@ -51,36 +51,6 @@
...
@@ -51,36 +51,6 @@
describe
(
"
An room shown in the rooms list
"
,
function
()
{
describe
(
"
An room shown in the rooms list
"
,
function
()
{
it
(
"
shows unread messages directed at the user
"
,
mock
.
initConverse
(
{
whitelisted_plugins
:
[
'
converse-roomslist
'
],
allow_bookmarks
:
false
// Makes testing easier, otherwise we
// have to mock stanza traffic.
},
function
(
_converse
)
{
var
room_jid
=
'
kitchen@conference.shakespeare.lit
'
;
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
kitchen
'
,
'
conference.shakespeare.lit
'
,
'
romeo
'
);
var
view
=
_converse
.
chatboxviews
.
get
(
room_jid
);
view
.
model
.
set
({
'
minimized
'
:
true
});
var
contact_jid
=
mock
.
cur_names
[
5
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
message
=
'
romeo: Your attention is required
'
;
var
nick
=
mock
.
chatroom_names
[
0
],
msg
=
$msg
({
from
:
room_jid
+
'
/
'
+
nick
,
id
:
(
new
Date
()).
getTime
(),
to
:
'
dummy@localhost
'
,
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
message
).
tree
();
view
.
handleMUCMessage
(
msg
);
expect
(
_converse
.
minimized_chats
.
toggleview
.
$
(
'
.unread-message-count
'
).
is
(
'
:visible
'
)).
toBeTruthy
();
expect
(
_converse
.
minimized_chats
.
toggleview
.
$
(
'
.unread-message-count
'
).
text
()).
toBe
(
'
1
'
);
var
room_el
=
_converse
.
rooms_list_view
.
el
.
querySelector
(
"
.available-chatroom
"
);
expect
(
_
.
includes
(
room_el
.
classList
,
'
unread-msgs
'
));
}));
it
(
"
can be closed
"
,
mock
.
initConverse
(
it
(
"
can be closed
"
,
mock
.
initConverse
(
{
whitelisted_plugins
:
[
'
converse-roomslist
'
],
{
whitelisted_plugins
:
[
'
converse-roomslist
'
],
allow_bookmarks
:
false
// Makes testing easier, otherwise we
allow_bookmarks
:
false
// Makes testing easier, otherwise we
...
@@ -106,5 +76,45 @@
...
@@ -106,5 +76,45 @@
expect
(
room_els
.
length
).
toBe
(
0
);
expect
(
room_els
.
length
).
toBe
(
0
);
expect
(
_converse
.
chatboxes
.
length
).
toBe
(
1
);
expect
(
_converse
.
chatboxes
.
length
).
toBe
(
1
);
}));
}));
it
(
"
shows unread messages directed at the user
"
,
mock
.
initConverse
(
{
whitelisted_plugins
:
[
'
converse-roomslist
'
],
allow_bookmarks
:
false
// Makes testing easier, otherwise we
// have to mock stanza traffic.
},
function
(
_converse
)
{
var
room_jid
=
'
kitchen@conference.shakespeare.lit
'
;
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
kitchen
'
,
'
conference.shakespeare.lit
'
,
'
romeo
'
);
var
view
=
_converse
.
chatboxviews
.
get
(
room_jid
);
view
.
model
.
set
({
'
minimized
'
:
true
});
var
contact_jid
=
mock
.
cur_names
[
5
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
nick
=
mock
.
chatroom_names
[
0
];
view
.
handleMUCMessage
(
$msg
({
from
:
room_jid
+
'
/
'
+
nick
,
id
:
(
new
Date
()).
getTime
(),
to
:
'
dummy@localhost
'
,
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
'
foo
'
).
tree
());
// If the user isn't mentioned, the counter doesn't get incremented, but the text of the room is bold
var
room_el
=
_converse
.
rooms_list_view
.
el
.
querySelector
(
"
.available-chatroom
"
);
expect
(
_
.
includes
(
room_el
.
classList
,
'
unread-msgs
'
));
// If the user is mentioned, the counter also gets updated
view
.
handleMUCMessage
(
$msg
({
from
:
room_jid
+
'
/
'
+
nick
,
id
:
(
new
Date
()).
getTime
(),
to
:
'
dummy@localhost
'
,
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
'
romeo: Your attention is required
'
).
tree
()
);
var
indicator_el
=
_converse
.
rooms_list_view
.
el
.
querySelector
(
"
.msgs-indicactor
"
);
expect
(
indicator_el
.
textContent
).
toBe
(
'
1
'
);
}));
});
});
}));
}));
src/converse-muc.js
View file @
c83026e5
...
@@ -362,6 +362,18 @@
...
@@ -362,6 +362,18 @@
_converse
.
ChatRoom
=
_converse
.
ChatBox
.
extend
({
_converse
.
ChatRoom
=
_converse
.
ChatBox
.
extend
({
defaults
:
_
.
extend
(
_converse
.
ChatBox
.
prototype
.
defaults
,
{
// For group chats, we distinguish between generally unread
// messages and those ones that specifically mention the
// user.
//
// To keep things simple, we reuse `num_unread` from
// _converse.ChatBox to indicate unread messages which
// mention the user and `num_unread_general` to indicate
// generally unread messages (which *includes* mentions!).
'
num_unread_general
'
:
0
}),
isUserMentioned
:
function
(
message
)
{
isUserMentioned
:
function
(
message
)
{
/* Returns a boolean to indicate whether the current user
/* Returns a boolean to indicate whether the current user
* was mentioned in a message.
* was mentioned in a message.
...
@@ -383,14 +395,19 @@
...
@@ -383,14 +395,19 @@
if
(
_
.
isNull
(
body
))
{
if
(
_
.
isNull
(
body
))
{
return
;
// The message has no text
return
;
// The message has no text
}
}
if
(
this
.
isNewMessage
(
stanza
)
&&
if
(
this
.
isNewMessage
(
stanza
)
&&
this
.
newMessageWillBeHidden
())
{
this
.
newMessageWillBeHidden
()
&&
this
.
save
({
'
num_unread_general
'
:
this
.
get
(
'
num_unread_general
'
)
+
1
});
this
.
isUserMentioned
(
body
.
textContent
))
{
if
(
this
.
isUserMentioned
(
body
.
textContent
))
{
this
.
save
({
'
num_unread
'
:
this
.
get
(
'
num_unread
'
)
+
1
});
this
.
save
({
'
num_unread
'
:
this
.
get
(
'
num_unread
'
)
+
1
}
);
_converse
.
incrementMsgCounter
(
);
_converse
.
incrementMsgCounter
();
}
}
}
},
},
clearUnreadMsgCounter
:
function
()
{
this
.
save
({
'
num_unread
'
:
0
});
this
.
save
({
'
num_unread_general
'
:
0
});
}
});
});
_converse
.
ChatRoomView
=
_converse
.
ChatBoxView
.
extend
({
_converse
.
ChatRoomView
=
_converse
.
ChatBoxView
.
extend
({
...
@@ -1919,7 +1936,7 @@
...
@@ -1919,7 +1936,7 @@
}
}
}
else
if
(
!
this
.
model
.
get
(
'
features_fetched
'
))
{
}
else
if
(
!
this
.
model
.
get
(
'
features_fetched
'
))
{
// The features for this room weren't fetched.
// The features for this room weren't fetched.
// That must mean it's a new room without locking
// That must mean it's a new room without locking
// (in which case Prosody doesn't send a 201 status),
// (in which case Prosody doesn't send a 201 status),
// otherwise the features would have been fetched in
// otherwise the features would have been fetched in
// the "initialize" method already.
// the "initialize" method already.
...
...
src/converse-roomslist.js
View file @
c83026e5
...
@@ -51,6 +51,7 @@
...
@@ -51,6 +51,7 @@
this
.
model
.
on
(
'
change:bookmarked
'
,
this
.
renderRoomsListElement
,
this
);
this
.
model
.
on
(
'
change:bookmarked
'
,
this
.
renderRoomsListElement
,
this
);
this
.
model
.
on
(
'
change:name
'
,
this
.
renderRoomsListElement
,
this
);
this
.
model
.
on
(
'
change:name
'
,
this
.
renderRoomsListElement
,
this
);
this
.
model
.
on
(
'
change:num_unread
'
,
this
.
renderRoomsListElement
,
this
);
this
.
model
.
on
(
'
change:num_unread
'
,
this
.
renderRoomsListElement
,
this
);
this
.
model
.
on
(
'
change:num_unread_general
'
,
this
.
renderRoomsListElement
,
this
);
this
.
model
.
on
(
'
remove
'
,
this
.
removeRoomsListElement
,
this
);
this
.
model
.
on
(
'
remove
'
,
this
.
removeRoomsListElement
,
this
);
var
cachekey
=
'
converse.roomslist
'
+
_converse
.
bare_jid
;
var
cachekey
=
'
converse.roomslist
'
+
_converse
.
bare_jid
;
...
...
src/templates/rooms_list_item.html
View file @
c83026e5
<dd
class=
"available-chatroom {[ if (num_unread
) { ]} unread-msgs {[ } ]}"
data-room-jid=
"{{{jid}}}"
>
<dd
class=
"available-chatroom {[ if (num_unread
_general) { ]} unread-msgs {[ } ]}"
data-room-jid=
"{{{jid}}}"
>
{[ if (num_unread) { ]}
{[ if (num_unread) { ]}
<span
class=
"msgs-indicactor"
>
{{{ num_unread }}}
</span>
<span
class=
"msgs-indicactor"
>
{{{ num_unread }}}
</span>
{[ } ]}
{[ } ]}
...
...
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