Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Ind.ie Projects
Heartbeat Node
Commits
c2b33c79
Unverified
Commit
c2b33c79
authored
Aug 27, 2015
by
Aral Balkan
Browse files
Added a timestamp formatter to fix messages in the Conversations timeline sent by others.
parent
37859a9e
Changes
2
Hide whitespace changes
Inline
Side-by-side
private/routes/conversation.coffee
View file @
c2b33c79
...
...
@@ -67,6 +67,25 @@ module.exports = (app) ->
return
'No date.'
timestampFormatter
=
(
messageID
)
->
messageIDParserRegExp
=
/^(\d{9})?-?(\d{4}-\d{2}-\d{2}T\d{2}_\d{2}_\d{2}\.\d{3}Z)-?(.*)?/
matches
=
messageID
.
match
messageIDParserRegExp
if
matches
!=
null
depracatedOptionalMessageClock
=
matches
[
1
]
timestamp
=
matches
[
2
]
optionalAccountHandle
=
matches
[
3
]
# Desearialise the timestamp.
timestamp
=
timestamp
.
replace
/_/g
,
':'
return
timestamp
else
# This should not happen. Return the current date.
return
new
Date
()
# Format the person’s name
personFormatter
=
(
messageID
)
->
personHandleDelimeter
=
messageID
.
lastIndexOf
(
'Z-'
)
...
...
@@ -137,4 +156,4 @@ module.exports = (app) ->
# TODO: Add the formatters to the messages themselves so we don’t have to duplicate them on the client.
response
.
render
'conversation'
,
{
personsAccountHandle
:
person
,
personsName
:
personsName
,
messages
:
messages
,
__set
:
{
formatters
:
{
messageBodyIDFormatter
:
messageBodyIDFormatter
,
messageStatusIDFormatter
:
messageStatusIDFormatter
,
profileImagePathFormatter
:
profileImagePathFormatter
,
personFormatter
:
personFormatter
,
postDateFormatter
:
postDateFormatter
}}}
response
.
render
'conversation'
,
{
personsAccountHandle
:
person
,
personsName
:
personsName
,
messages
:
messages
,
__set
:
{
formatters
:
{
messageBodyIDFormatter
:
messageBodyIDFormatter
,
messageStatusIDFormatter
:
messageStatusIDFormatter
,
profileImagePathFormatter
:
profileImagePathFormatter
,
personFormatter
:
personFormatter
,
postDateFormatter
:
postDateFormatter
,
timestampFormatter
:
timestampFormatter
}}}
private/views/conversation.html
View file @
c2b33c79
...
...
@@ -27,7 +27,7 @@
<div
class=
"image-and-body"
>
<img
class=
"profileImage"
data-set-attribute=
'src message.key profileImagePathFormatter'
>
<div
class=
"bodyText"
data-set-text=
'html message.value'
>
Message body HTML
</div>
<div
class=
"meta"
><span
class=
'postDate'
data-set-attribute=
'data-timestamp message.key'
data-set-text=
'message.key postDateFormatter'
></span><span
data-set-text=
'message.key personFormatter'
></span></div>
<div
class=
"meta"
><span
class=
'postDate'
data-set-attribute=
'data-timestamp message.key
timestampFormatter
'
data-set-text=
'message.key postDateFormatter'
></span><span
data-set-text=
'message.key personFormatter'
></span></div>
</div>
</div>
<!-- <div class='messageStatus' data-set-attribute='id message.key messageStatusIDFormatter'></div>-->
...
...
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