mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-01 11:40:25 +00:00
update chat messages timestamp
This commit is contained in:
parent
75ce46d4af
commit
a81e77f0ff
2 changed files with 15 additions and 2 deletions
|
|
@ -153,3 +153,16 @@ habitrpg
|
|||
}
|
||||
}]);
|
||||
|
||||
habitrpg.directive('fromNow', ['$interval', function($interval){
|
||||
return function(scope, element, attr){
|
||||
var updateText = function(){ element.text(moment(scope.message.timestamp).fromNow()) };
|
||||
updateText();
|
||||
// Update the counter every 60secs if was sent less than one hour ago otherwise every hour
|
||||
// OPTIMIZATION, every time the interval is run, update the interval time
|
||||
var intervalTime = moment().diff(scope.message.timestamp, 'minute') < 60 ? 60000 : 3600000;
|
||||
var interval = $interval(function(){ updateText() }, intervalTime, false);
|
||||
scope.$on('$destroy', function() {
|
||||
$interval.cancel(interval);
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ li(ng-repeat='message in group.chat', ng-class='{highlight: isUserMentioned(user
|
|||
|
|
||||
span(ng-bind-html="message.text | linky:'_blank'")
|
||||
| -
|
||||
span.muted.time
|
||||
| {{moment(message.timestamp).fromNow() + ' '}}
|
||||
span.muted.time(from-now='message.timestamp')
|
||||
a(ng-show='user.contributor.admin || message.uuid == user.id', ng-click='deleteChatMessage(group, message)')
|
||||
|
|
||||
i.icon-remove(tooltip='Delete')
|
||||
|
|
|
|||
Loading…
Reference in a new issue