1
0
mirror of https://github.com/moparisthebest/mail synced 2024-12-21 23:08:50 -05:00

moved ordering of emails to list view instead of email dao

This commit is contained in:
Tankred Hase 2013-03-21 21:58:56 +01:00
parent 7758b144dc
commit 02076cff40
3 changed files with 7 additions and 9 deletions

View File

@ -60,10 +60,7 @@ app.dao.EmailDAO = function(_, crypto, devicestorage, cloudstorage) {
// get items from storage
devicestorage.listItems('email_' + folderName ,offset ,num, function(decryptedList) {
// parse to backbone model collection
collection = new app.model.EmailCollection(decryptedList);
// reverse order so that mails with the most recent dat will be displayed first
collection.models.reverse();
collection = new app.model.EmailCollection(decryptedList);
// cache collection in folder memory
if (decryptedList.length > 0) {

View File

@ -50,18 +50,19 @@ app.view.MessageListView = Backbone.View.extend({
var self = this,
page = $(this.el),
list = page.find('#message-list'),
listItemArgs;
listItemArgs, i, email;
$.mobile.loading('show', { text: 'decrypting...', textVisible: true });
this.dao.listItems(this.folder, 0, 10, function(collection) {
// clear list
list.html('');
// append items to list
_.each(collection.models, function(email) {
// append items to list in reverse order so mails with the most recent date will be displayed first
for (i = collection.models.length - 1; i >= 0; i--) {
email = collection.at(i);
listItemArgs = {account: self.options.account, folder: self.folder, model: email};
list.append(new app.view.MessageListItemView(listItemArgs).render().el);
}, this);
}
// refresh list view
list.listview('refresh');

View File

@ -60,7 +60,7 @@ asyncTest("Persist test emails", 2, function() {
asyncTest("List Email models", 1, function() {
emaildao_test.emailDao.listItems('inbox', 0, emaildao_test.list.length, function(collection) {
var gotten = collection.toJSON(),
reference = emaildao_test.list.toJSON().reverse();
reference = emaildao_test.list.toJSON();
deepEqual(gotten, reference, 'Compare collection');