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:
parent
7758b144dc
commit
02076cff40
@ -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) {
|
||||
|
@ -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');
|
||||
|
@ -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');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user