pull/2778/head
Marcelo Schmidt 10 years ago
parent 8ab82cbf25
commit d0e7b91cef
  1. 14
      server/methods/loadSurroundingMessages.coffee

@ -8,15 +8,16 @@ Meteor.methods
unless Meteor.call 'canAccessRoom', message.rid, fromId
return false
if not RocketChat.settings.get 'Message_ShowEditedStatus'
options.fields = { 'editedAt': 0 }
limit = limit - 1
options =
sort:
ts: -1
limit: Math.ceil(limit/2)
if not RocketChat.settings.get 'Message_ShowEditedStatus'
options.fields = { 'editedAt': 0 }
records = RocketChat.models.Messages.findVisibleByRoomIdBeforeTimestamp(message.rid, message.ts, options).fetch()
messages = _.map records, (message) ->
message.starred = _.findWhere message.starred, { _id: fromId }
@ -26,10 +27,9 @@ Meteor.methods
messages.push message
options =
sort:
ts: 1
limit: Math.floor(limit/2)
options.sort = { ts: 1 }
options.limit = Math.floor(limit/2)
records = RocketChat.models.Messages.findVisibleByRoomIdAfterTimestamp(message.rid, message.ts, options).fetch()
afterMessages = _.map records, (message) ->
message.starred = _.findWhere message.starred, { _id: fromId }

Loading…
Cancel
Save