2020-09-16 22:33:53 +08:00
|
|
|
import { AbstractCollectionModel } from 'Model/AbstractCollection';
|
2020-09-16 21:44:36 +08:00
|
|
|
import { MessageModel } from 'Model/Message';
|
2023-02-14 17:11:25 +08:00
|
|
|
import { MessageUserStore } from 'Stores/User/Message';
|
2020-09-16 21:44:36 +08:00
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
2020-09-16 22:33:53 +08:00
|
|
|
export class MessageCollectionModel extends AbstractCollectionModel
|
2020-09-16 21:44:36 +08:00
|
|
|
{
|
2020-09-16 22:33:53 +08:00
|
|
|
/*
|
2020-09-16 21:44:36 +08:00
|
|
|
constructor() {
|
|
|
|
super();
|
2023-02-16 17:55:23 +08:00
|
|
|
this.filtered
|
2023-01-25 01:58:25 +08:00
|
|
|
this.folder
|
2022-06-02 04:50:35 +08:00
|
|
|
this.totalEmails
|
2023-02-16 17:55:23 +08:00
|
|
|
this.totalThreads
|
2022-12-29 20:40:46 +08:00
|
|
|
this.threadUid
|
|
|
|
this.newMessages
|
|
|
|
this.offset
|
|
|
|
this.limit
|
|
|
|
this.search
|
2023-02-16 17:55:23 +08:00
|
|
|
this.limited
|
2020-09-16 21:44:36 +08:00
|
|
|
}
|
2020-09-16 22:33:53 +08:00
|
|
|
*/
|
2020-09-16 21:44:36 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {?Object} json
|
|
|
|
* @returns {MessageCollectionModel}
|
|
|
|
*/
|
2023-03-06 18:36:23 +08:00
|
|
|
static reviveFromJson(object/*, cached*/) {
|
2023-02-14 17:11:25 +08:00
|
|
|
let msg = MessageUserStore.message();
|
2020-10-18 17:46:22 +08:00
|
|
|
return super.reviveFromJson(object, message => {
|
2023-02-14 17:11:25 +08:00
|
|
|
// If message is currently viewed, use that.
|
|
|
|
// Maybe then use msg.revivePropertiesFromJson(message) ?
|
|
|
|
message = (msg && msg.hash === message.hash) ? msg : MessageModel.reviveFromJson(message);
|
2020-10-19 01:46:47 +08:00
|
|
|
if (message) {
|
|
|
|
message.deleted(false);
|
|
|
|
return message;
|
2020-10-18 17:46:22 +08:00
|
|
|
}
|
|
|
|
});
|
2020-09-16 21:44:36 +08:00
|
|
|
}
|
|
|
|
}
|