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
06a6d6c4
Commit
06a6d6c4
authored
Jul 19, 2015
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor out code for showing a new day in the chat box.
parent
3ba12580
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
+13
-11
converse.js
converse.js
+13
-11
No files found.
converse.js
View file @
06a6d6c4
...
...
@@ -1233,7 +1233,7 @@
},
initialize
:
function
()
{
this
.
model
.
messages
.
on
(
'
add
'
,
this
.
onMessageAdded
,
this
);
this
.
model
.
messages
.
on
(
'
add
'
,
_
.
compose
(
this
.
onMessageAdded
,
this
.
showNewDay
)
,
this
);
this
.
model
.
on
(
'
show
'
,
this
.
show
,
this
);
this
.
model
.
on
(
'
destroy
'
,
this
.
hide
,
this
);
// TODO check for changed fullname as well
...
...
@@ -1461,17 +1461,15 @@
return
this
.
scrollDown
();
},
onMessageAdded
:
function
(
message
)
{
showNewDay
:
function
(
message
)
{
/* If this message is on a different day than the one received
* prior, then indicate it on the chatbox.
*/
var
time
=
message
.
get
(
'
time
'
),
times
=
this
.
model
.
messages
.
pluck
(
'
time
'
),
previous_message
,
idx
,
this_date
,
prev_date
,
text
,
match
;
// If this message is on a different day than the one received
// prior, then indicate it on the chatbox.
idx
=
_
.
indexOf
(
times
,
time
)
-
1
;
idx
=
_
.
indexOf
(
this
.
model
.
messages
.
pluck
(
'
time
'
),
time
)
-
1
,
this_date
,
prev_date
;
if
(
idx
>=
0
)
{
previous_message
=
this
.
model
.
messages
.
at
(
idx
);
prev_date
=
moment
(
previous_message
.
get
(
'
time
'
));
prev_date
=
moment
(
this
.
model
.
messages
.
at
(
idx
).
get
(
'
time
'
));
if
(
prev_date
.
isBefore
(
time
,
'
day
'
))
{
this_date
=
moment
(
time
);
this
.
$content
.
append
(
converse
.
templates
.
new_day
({
...
...
@@ -1480,6 +1478,10 @@
}));
}
}
return
message
;
},
onMessageAdded
:
function
(
message
)
{
if
(
!
message
.
get
(
'
message
'
))
{
if
(
message
.
get
(
'
chat_state
'
)
===
COMPOSING
)
{
this
.
showStatusNotification
(
message
.
get
(
'
fullname
'
)
+
'
'
+
__
(
'
is typing
'
));
...
...
@@ -2692,7 +2694,7 @@
is_chatroom
:
true
,
initialize
:
function
()
{
this
.
model
.
messages
.
on
(
'
add
'
,
this
.
onMessageAdded
,
this
);
this
.
model
.
messages
.
on
(
'
add
'
,
_
.
compose
(
this
.
onMessageAdded
,
this
.
showNewDay
)
,
this
);
this
.
model
.
on
(
'
change:minimized
'
,
function
(
item
)
{
if
(
item
.
get
(
'
minimized
'
))
{
this
.
hide
();
...
...
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