mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-11-14 19:54:43 +08:00
51 lines
1 KiB
JavaScript
51 lines
1 KiB
JavaScript
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) {
|
|
let newCount = 0;
|
|
return super.reviveFromJson(object, message => {
|
|
message = MessageModel.reviveFromJson(message);
|
|
if (message) {
|
|
if (hasNewMessageAndRemoveFromCache(message.folder, message.uid) && 5 >= newCount) {
|
|
++newCount;
|
|
}
|
|
|
|
message.deleted(false);
|
|
|
|
cached ? MessageFlagsCache.initMessage(message) : MessageFlagsCache.store(message);
|
|
return message;
|
|
}
|
|
});
|
|
}
|
|
}
|