snappymail/dev/Model/MessageCollection.js

52 lines
1 KiB
JavaScript
Raw Normal View History

import { AbstractCollectionModel } from 'Model/AbstractCollection';
import { MessageModel } from 'Model/Message';
import {
MessageFlagsCache,
hasNewMessageAndRemoveFromCache
} from 'Common/Cache';
'use strict';
export class MessageCollectionModel extends AbstractCollectionModel
{
/*
constructor() {
super();
this.Filtered
this.Folder
this.FolderHash
this.Limit
this.MessageCount
this.MessageUnseenCount
this.MessageResultCount
this.NewMessages
this.Offset
this.Search
this.ThreadUid
this.UidNext
}
*/
/**
* @param {?Object} json
* @returns {MessageCollectionModel}
*/
static reviveFromJson(object, cached) {
2020-10-18 17:46:22 +08:00
let newCount = 0;
return super.reviveFromJson(object, message => {
message = MessageModel.reviveFromJson(message);
if (message) {
2020-10-23 21:15:54 +08:00
if (hasNewMessageAndRemoveFromCache(message.folder, message.uid) && 5 >= newCount) {
++newCount;
}
message.deleted(false);
cached ? MessageFlagsCache.initMessage(message) : MessageFlagsCache.store(message);
return message;
2020-10-18 17:46:22 +08:00
}
});
}
}