snappymail/dev/Model/MessageCollection.js

42 lines
950 B
JavaScript
Raw Normal View History

import { AbstractCollectionModel } from 'Model/AbstractCollection';
import { MessageModel } from 'Model/Message';
import { MessageUserStore } from 'Stores/User/Message';
'use strict';
export class MessageCollectionModel extends AbstractCollectionModel
{
/*
constructor() {
super();
this.filtered
this.folder
this.totalEmails
this.totalThreads
this.threadUid
this.newMessages
this.offset
this.limit
this.search
this.limited
}
*/
/**
* @param {?Object} json
* @returns {MessageCollectionModel}
*/
2023-03-06 18:36:23 +08:00
static reviveFromJson(object/*, cached*/) {
let msg = MessageUserStore.message();
2020-10-18 17:46:22 +08:00
return super.reviveFromJson(object, message => {
// If message is currently viewed, use that.
// Maybe then use msg.revivePropertiesFromJson(message) ?
message = (msg && msg.hash === message.hash) ? msg : MessageModel.reviveFromJson(message);
if (message) {
message.deleted(false);
return message;
2020-10-18 17:46:22 +08:00
}
});
}
}