|
|
@ -5,6 +5,7 @@ var core = require('web.core'); |
|
|
|
var session = require('web.session'); |
|
|
|
var Manager = require('mail.Manager'); |
|
|
|
var Mailbox = require('mail.model.Mailbox'); |
|
|
|
var SearchableThread = require('mail.model.SearchableThread'); |
|
|
|
|
|
|
|
var _t = core._t; |
|
|
|
|
|
|
@ -18,15 +19,52 @@ Manager.include({ |
|
|
|
this._addMailbox({ |
|
|
|
id: 'channel_sent', |
|
|
|
name: _t("Sent Messages"), |
|
|
|
mailboxCounter: data.needaction_inbox_counter || 0, |
|
|
|
mailboxCounter: 0, |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
}); |
|
|
|
|
|
|
|
SearchableThread.include({ |
|
|
|
_fetchMessages: function (pDomain, loadMore) { |
|
|
|
var self = this; |
|
|
|
if (this._id !== 'mailbox_channel_sent') { |
|
|
|
return this._super(pDomain, loadMore); |
|
|
|
} |
|
|
|
|
|
|
|
_makeMessage: function (data) { |
|
|
|
var message = this._super(data); |
|
|
|
message._addThread('mailbox_channel_sent'); |
|
|
|
return message; |
|
|
|
// this is a copy-paste from super method
|
|
|
|
var domain = this._getThreadDomain(); |
|
|
|
var cache = this._getCache(pDomain); |
|
|
|
if (pDomain) { |
|
|
|
domain = domain.concat(pDomain || []); |
|
|
|
} |
|
|
|
if (loadMore) { |
|
|
|
var minMessageID = cache.messages[0].getID(); |
|
|
|
domain = [['id', '<', minMessageID]].concat(domain); |
|
|
|
} |
|
|
|
return this._rpc({ |
|
|
|
model: 'mail.message', |
|
|
|
method: 'message_fetch', |
|
|
|
args: [domain], |
|
|
|
kwargs: this._getFetchMessagesKwargs(), |
|
|
|
}).then(function (messages) { |
|
|
|
// except this function. It adds the required thread to downloaded messages
|
|
|
|
_.each(messages, function(m){ |
|
|
|
m.channel_ids.push('mailbox_channel_sent'); |
|
|
|
}); |
|
|
|
if (!cache.allHistoryLoaded) { |
|
|
|
cache.allHistoryLoaded = messages.length < self._FETCH_LIMIT; |
|
|
|
} |
|
|
|
cache.loaded = true; |
|
|
|
_.each(messages, function (message) { |
|
|
|
self.call('mail_service', 'addMessage', message, { |
|
|
|
silent: true, |
|
|
|
domain: pDomain, |
|
|
|
}); |
|
|
|
}); |
|
|
|
cache = self._getCache(pDomain || []); |
|
|
|
return cache.messages; |
|
|
|
}); |
|
|
|
}, |
|
|
|
}); |
|
|
|
|
|
|
|