Skip to content

Commit

Permalink
No relative date on the comment after a day, makes no sense...
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Jan 16, 2018
1 parent 340c998 commit 46e43c6
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions js/views/chatview.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@
var data = _.extend({}, commentModel.attributes, {
actorDisplayName: actorDisplayName,
timestamp: timestamp,
date: OC.Util.relativeModifiedDate(timestamp),
altDate: OC.Util.formatDate(timestamp, 'LL LTS'),
date: moment(timestamp, 'x').diff(moment()) > -86400000 ? OC.Util.relativeModifiedDate(timestamp) : OC.Util.formatDate(timestamp, 'LT'),
altDate: OC.Util.formatDate(timestamp),
formattedMessage: formattedMessage
});
return data;
Expand Down Expand Up @@ -209,7 +209,7 @@
model.set('date', new Date(model.get('timestamp') * 1000));

if (!this._lastAddedMessageModel || !this._modelsHaveSameDate(this._lastAddedMessageModel, model)) {
if (this._oldestOnTopLayout) {
if (!this._lastAddedMessageModel || this._oldestOnTopLayout) {
$el.attr('data-date', this._getDateSeparator(model.get('date')));
$el.addClass('showDate');
} else {
Expand Down Expand Up @@ -244,10 +244,10 @@
var date = moment(timestamp, 'x'),
today = moment(),
dayOfYear = OC.Util.formatDate(date, 'YYYY-DDD'),
dateOfToday = OC.Util.formatDate(today, 'YYYY-DDD');
dayOfYearToday = OC.Util.formatDate(today, 'YYYY-DDD');

var relativePrefix = '';
if (dayOfYear === dateOfToday) {
if (dayOfYear === dayOfYearToday) {
relativePrefix = t('spreed', 'Today');
} else {
var yesterday = OC.Util.formatDate(today.subtract(1, 'd'), 'YYYY-DDD');
Expand All @@ -260,7 +260,10 @@
}


return relativePrefix + ', ' + OC.Util.formatDate(timestamp, 'LL');
return t('spreed', '{relativeDate}, {absoluteDate}', {
relativeDate: relativePrefix,
absoluteDate: OC.Util.formatDate(timestamp, 'LL')
});
},

_modelsHaveSameActor: function(model1, model2) {
Expand Down

0 comments on commit 46e43c6

Please sign in to comment.