Skip to content
Snippets Groups Projects
Commit 60e4620b authored by Zach Auclair's avatar Zach Auclair
Browse files

feat(message-ui/edit-info): add information about message editor

This comes in the form of the user's avatar, along with a hover
title that shows username and edit time. As a side note, this
requires us to start saving 'editBy' id as part of message updates.

This has been tested with all 4 of the current avatar methods.

fixes #824
parent 93024dea
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,7 @@ Meteor.methods
Tracker.nonreactive ->
message.editBy = Meteor.userId()
message.ets = new Date(Date.now() + TimeSync.serverOffset())
message = RocketChat.callbacks.run 'beforeSaveMessage', message
......
wasEdited = (msg) ->
msg.ets and msg.t not in ['s', 'p', 'f', 'r', 'au', 'ru', 'ul', 'nu', 'wm', 'uj', 'rm']
Template.message.helpers
actions: ->
return RocketChat.MessageAction.getButtons(this)
......@@ -46,8 +48,13 @@ Template.message.helpers
system: ->
return 'system' if this.t in ['s', 'p', 'f', 'r', 'au', 'ru', 'ul', 'nu', 'wm', 'uj', 'rm']
edited: ->
return @ets and @t not in ['s', 'p', 'f', 'r', 'au', 'ru', 'ul', 'nu', 'wm', 'uj', 'rm']
edited: -> wasEdited(@)
editTime: ->
return "" unless wasEdited(@)
moment(@ets).format('LL hh:mma') #TODO profile pref for 12hr/24hr clock?
editedBy: ->
return "" unless wasEdited(@)
Meteor.users.findOne(@editBy ? Meteor.userId())?.username
pinned: ->
return this.pinned
canEdit: ->
......
......@@ -5,7 +5,17 @@
<span class="info">
<span class="time">{{time}}</span>
{{#if edited}}
<span class="edited">({{_ "edited"}})</span>
<span class="edited">
(<a
title='{{_ "edited"}} at {{editTime}} {{_ "by"}} {{editedBy}}'
class="thumb thumb-small user-card-message"
href="#"
data-username="{{editedBy}}"
tabindex="1">
{{> avatar username=editedBy}}
</a>
{{_ "edited"}})
</span>
{{/if}}
{{#if private}}
<span class="private">{{_ "Only_you_can_see_this_message"}}</span>
......
......@@ -2448,6 +2448,13 @@ a.github-fork {
display: block;
width: 40px;
height: 40px;
&.thumb-small {
position: initial;
width: 20px;
height: 20px;
display: inline-block;
vertical-align: bottom;
}
}
.info {
font-size: 12px;
......
......@@ -29,6 +29,8 @@ Meteor.methods
RocketChat.models.Messages.cloneAndSaveAsHistoryById originalMessage._id
message.ets = new Date()
# save who message was edited by
message.editBy = Meteor.userId()
if urls = message.msg.match /([A-Za-z]{3,9}):\/\/([-;:&=\+\$,\w]+@{1})?([-A-Za-z0-9\.]+)+:?(\d+)?((\/[-\+=!:~%\/\.@\,\w]+)?\??([-\+=&!:;%@\/\.\,\w]+)?#?([\w]+)?)?/g
message.urls = urls.map (url) -> url: url
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment