diff options
| author | Alexandre Kühn <aku@odoo.com> | 2018-07-04 15:57:03 +0200 |
|---|---|---|
| committer | Alexandre Kühn <aku@odoo.com> | 2018-07-19 13:58:34 +0200 |
| commit | 915da49d173e9ab8d0c6d94cbeec124c83d23fc7 (patch) | |
| tree | d7fe30d4a4c7f1a6923b88c91ac98582ee6500f4 /addons/mail/static/src/js/models/threads/thread_with_cache.js | |
| parent | ec8c505bc1c9ec21939e9ffef53a9cc6f63f30c7 (diff) | |
[IMP] mail, *: template rendering with abstract thread, adapt thread instantiation, thread `getMessages`/`fetchMessages`, and create mode document thread.
* = im_livechat, im_support
- thread widget now uses abstract thread in `render` method
- thread models have their `init` parameters changed, so that the parent may be optional
- reworked 'creating a new record...' in chatter in create mode:
> new model CreateModeDocumentThread, which basically is a fake document thread
with a fake message for its rendering in create mode of the chatter
> special rendering method of thread_widget for such case: `renderChatterCreateMode`
- renamed thread methods previously named `getMessages` to `fetchMessages`:
> in order to not conflict with `getMessages`, used for rendering
> now, `getMessages` always get messages that are locally,
while `fetchMessages` may fetch messages.
TODO:
- special thread model for im_livechat (rendering is broken ATM)
Diffstat (limited to 'addons/mail/static/src/js/models/threads/thread_with_cache.js')
| -rw-r--r-- | addons/mail/static/src/js/models/threads/thread_with_cache.js | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/addons/mail/static/src/js/models/threads/thread_with_cache.js b/addons/mail/static/src/js/models/threads/thread_with_cache.js index f25a19005f2..ef064072bbf 100644 --- a/addons/mail/static/src/js/models/threads/thread_with_cache.js +++ b/addons/mail/static/src/js/models/threads/thread_with_cache.js @@ -16,9 +16,11 @@ var session = require('web.session'); var ThreadWithCache = Thread.extend({ /** * @override - * @param {integer} [data.seen_message_id=undefined] + * @param {Object} params + * @param {Object} params.data + * @param {integer} [params.data.seen_message_id=undefined] */ - init: function (parent, data) { + init: function (params) { this._super.apply(this, arguments); this._cache = { @@ -28,7 +30,7 @@ var ThreadWithCache = Thread.extend({ messages: [], } }; - this._lastSeenMessageID = data.seen_message_id; + this._lastSeenMessageID = params.data.seen_message_id; }, //-------------------------------------------------------------------------- @@ -53,19 +55,11 @@ var ThreadWithCache = Thread.extend({ } }, /** - * Get the last seen message for a given thread - * - * @return {integer|null} last seen message ID (if any) - */ - getLastSeenMessageID: function () { - return this._lastSeenMessageID || null; - }, - /** * @override * @param {Array} [domain] * @param {boolean} [loadMore=false] */ - getMessages: function (domain, loadMore) { + fetchMessages: function (domain, loadMore) { if (loadMore) { return this._fetchMessages(domain, true); } @@ -77,11 +71,19 @@ var ThreadWithCache = Thread.extend({ } }, /** - * @private - * @return {boolean} true if there is at least a message, false otherwise + * Get the last seen message for a given thread + * + * @return {integer|null} last seen message ID (if any) + */ + getLastSeenMessageID: function () { + return this._lastSeenMessageID || null; + }, + /** + * @override + * @return {mail.model.Message[]} */ - hasMessages: function () { - return !!(_.last(this._cache['[]'].messages)); + getMessages: function () { + return this._cache['[]'].messages; }, /** * Invalidate the caches of the thread |
