Ind.ie is now Small Technology Foundation.
Commit 37859a9e authored by Aral Balkan's avatar Aral Balkan

Added a timestamp formatter to fix messages in the All Friends timeline sent by others.

parent 7680e639
......@@ -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-')
......@@ -114,4 +133,4 @@ module.exports = (app) ->
# TODO: Add the formatters to the messages themselves so we don’t have to duplicate them on the client.
# Reverse the message order to match that of the Cocoa client.
response.render 'all-friends', {messages: messages, __set: { formatters: {messageBodyIDFormatter: messageBodyIDFormatter, messageStatusIDFormatter: messageStatusIDFormatter, profileImagePathFormatter: profileImagePathFormatter, personFormatter:personFormatter, postDateFormatter:postDateFormatter}}}
response.render 'all-friends', {messages: messages, __set: { formatters: {messageBodyIDFormatter: messageBodyIDFormatter, messageStatusIDFormatter: messageStatusIDFormatter, profileImagePathFormatter: profileImagePathFormatter, personFormatter:personFormatter, postDateFormatter: postDateFormatter, timestampFormatter: timestampFormatter}}}
......@@ -33,7 +33,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>-->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment