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
da3670d9
Commit
da3670d9
authored
Jan 03, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MUC Join/Leave messages now also show a new day indicator
parent
46e54667
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
112 additions
and
147 deletions
+112
-147
CHANGES.md
CHANGES.md
+1
-0
spec/chatroom.js
spec/chatroom.js
+76
-131
src/converse-chatview.js
src/converse-chatview.js
+25
-12
src/converse-muc.js
src/converse-muc.js
+10
-4
No files found.
CHANGES.md
View file @
da3670d9
...
...
@@ -34,6 +34,7 @@
-
Show status messages in an MUC room when a user's role changes.
-
In MUC chat rooms, collapse multiple, consecutive join/leave messages.
-
Performance improvements for rendering private chats, rooms and the contacts roster.
-
MUC Leave/Join messages now also show a new day indicator if applicable.
### API changes
-
New API method
`_converse.disco.supports`
to check whether a certain
...
...
spec/chatroom.js
View file @
da3670d9
This diff is collapsed.
Click to expand it.
src/converse-chatview.js
View file @
da3670d9
...
...
@@ -386,21 +386,37 @@
/* Inserts an indicator into the chat area, showing the
* day as given by the passed in date.
*
* The indicator is only inserted if necessary.
*
* Parameters:
* (HTMLElement) next_msg_el - The message element before
* which the day indicator element must be inserted.
* This element must have a "data-isodate" attribute
* which specifies its creation date.
*/
const
date
=
next_msg_el
.
getAttribute
(
'
data-isodate
'
),
day_date
=
moment
(
date
).
startOf
(
'
day
'
);
const
prev_msg_el
=
this
.
getPreviousMessageElement
(
next_msg_el
),
prev_msg_date
=
_
.
isNull
(
prev_msg_el
)
?
null
:
prev_msg_el
.
getAttribute
(
'
data-isodate
'
),
next_msg_date
=
next_msg_el
.
getAttribute
(
'
data-isodate
'
);
if
(
_
.
isNull
(
prev_msg_date
)
||
moment
(
next_msg_date
).
isAfter
(
prev_msg_date
,
'
day
'
))
{
const
day_date
=
moment
(
next_msg_date
).
startOf
(
'
day
'
);
next_msg_el
.
insertAdjacentHTML
(
'
beforeBegin
'
,
tpl_new_day
({
'
isodate
'
:
day_date
.
format
(),
'
datestring
'
:
day_date
.
format
(
"
dddd MMM Do YYYY
"
)
})
);
}
},
next_msg_el
.
insertAdjacentHTML
(
'
beforeBegin
'
,
tpl_new_day
({
'
isodate
'
:
day_date
.
format
(),
'
datestring
'
:
day_date
.
format
(
"
dddd MMM Do YYYY
"
)
})
);
getPreviousMessageElement
(
el
)
{
let
prev_msg_el
=
el
.
previousSibling
;
while
(
!
_
.
isNull
(
prev_msg_el
)
&&
!
u
.
hasClass
(
prev_msg_el
,
'
message
'
)
&&
!
u
.
hasClass
(
prev_msg_el
,
'
chat-info
'
))
{
prev_msg_el
=
prev_msg_el
.
previousSibling
}
return
prev_msg_el
;
},
getLastMessageElement
()
{
...
...
@@ -476,14 +492,11 @@
if
(
_
.
isNull
(
previous_msg_date
))
{
this
.
content
.
insertAdjacentElement
(
'
afterbegin
'
,
message_el
);
this
.
insertDayIndicator
(
message_el
);
}
else
{
const
previous_msg_el
=
sizzle
(
`[data-isodate="
${
previous_msg_date
}
"]:last`
,
this
.
content
).
pop
();
previous_msg_el
.
insertAdjacentElement
(
'
afterend
'
,
message_el
);
if
(
current_msg_date
.
isAfter
(
previous_msg_date
,
'
day
'
))
{
this
.
insertDayIndicator
(
message_el
);
}
}
this
.
insertDayIndicator
(
message_el
);
this
.
scrollDown
();
},
...
...
src/converse-muc.js
View file @
da3670d9
...
...
@@ -1837,9 +1837,10 @@
const
nick
=
Strophe
.
getResourceFromJid
(
stanza
.
getAttribute
(
'
from
'
));
const
stat
=
stanza
.
querySelector
(
'
status
'
);
const
last_el
=
this
.
content
.
lastElementChild
;
if
(
_
.
includes
(
_
.
get
(
last_el
,
'
classList
'
,
[]),
'
chat-info
'
)
&&
_
.
get
(
last_el
,
'
dataset
'
,
{}).
leave
===
`"
${
nick
}
"`
)
{
last_el
.
outerHTML
=
last_el
.
outerHTML
=
tpl_info
({
'
data
'
:
`data-leavejoin="
${
nick
}
"`
,
'
isodate
'
:
moment
().
format
(),
...
...
@@ -1860,7 +1861,9 @@
last_el
.
outerHTML
=
tpl_info
(
data
);
}
else
{
this
.
content
.
insertAdjacentHTML
(
'
beforeend
'
,
tpl_info
(
data
));
const
el
=
u
.
stringToElement
(
tpl_info
(
data
));
this
.
content
.
insertAdjacentElement
(
'
beforeend
'
,
el
);
this
.
insertDayIndicator
(
el
);
}
}
this
.
scrollDown
();
...
...
@@ -1877,7 +1880,7 @@
if
(
_
.
get
(
stat
,
'
textContent
'
))
{
message
=
message
+
'
"
'
+
stat
.
textContent
+
'
"
'
;
}
last_el
.
outerHTML
=
last_el
.
outerHTML
=
tpl_info
({
'
data
'
:
`data-joinleave="
${
nick
}
"`
,
'
isodate
'
:
moment
().
format
(),
...
...
@@ -1890,6 +1893,7 @@
}
const
data
=
{
'
message
'
:
message
,
'
isodate
'
:
moment
().
format
(),
'
data
'
:
`data-leave="
${
nick
}
"`
}
if
(
_
.
includes
(
_
.
get
(
last_el
,
'
classList
'
,
[]),
'
chat-info
'
)
&&
...
...
@@ -1897,7 +1901,9 @@
last_el
.
outerHTML
=
tpl_info
(
data
);
}
else
{
this
.
content
.
insertAdjacentHTML
(
'
beforeend
'
,
tpl_info
(
data
));
const
el
=
u
.
stringToElement
(
tpl_info
(
data
));
this
.
content
.
insertAdjacentElement
(
'
beforeend
'
,
el
);
this
.
insertDayIndicator
(
el
);
}
}
this
.
scrollDown
();
...
...
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