Skip to content

Commit

Permalink
Merge pull request sj26#78 from asynchrony/master
Browse files Browse the repository at this point in the history
Sort messages from newest to oldest [also closes sj26#70].
  • Loading branch information
sj26 committed Feb 10, 2013
2 parents fbd6b94 + 2ae395a commit c971f54
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/mail_catcher/mail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def latest_created_at
end

def messages
@messages_query ||= db.prepare "SELECT id, sender, recipients, subject, size, created_at FROM message ORDER BY created_at ASC"
@messages_query ||= db.prepare "SELECT id, sender, recipients, subject, size, created_at FROM message ORDER BY created_at DESC"
@messages_query.execute.map do |row|
Hash[row.fields.zip(row)].tap do |message|
message["recipients"] &&= ActiveSupport::JSON.decode message["recipients"]
Expand Down
2 changes: 1 addition & 1 deletion public/javascripts/application.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class MailCatcher
$('#messages tbody tr').show()

addMessage: (message) ->
$('#messages tbody').append \
$('#messages tbody').prepend \
$('<tr />').attr('data-message-id', message.id.toString())
.append($('<td/>').text(message.sender or "No sender").toggleClass("blank", !message.sender))
.append($('<td/>').text((message.recipients || []).join(', ') or "No receipients").toggleClass("blank", !message.recipients.length))
Expand Down
35 changes: 26 additions & 9 deletions public/javascripts/application.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c971f54

Please sign in to comment.