[IMP] mail, *: access models without env in components
* = im_livechat, snailmail, website_livechat And finally remove env.models as this was the last remaining usage. Part of task-2582313
This commit is contained in:
@@ -18,7 +18,7 @@ patch(components.DiscussSidebar.prototype, 'im_livechat/static/src/components/di
|
||||
* @returns {mail.thread[]}
|
||||
*/
|
||||
quickSearchOrderedAndPinnedLivechatList() {
|
||||
const allOrderedAndPinnedLivechats = this.env.models['mail.thread']
|
||||
const allOrderedAndPinnedLivechats = this.messaging.models['mail.thread']
|
||||
.all(thread =>
|
||||
thread.channel_type === 'livechat' &&
|
||||
thread.isPinned &&
|
||||
|
||||
@@ -20,7 +20,7 @@ patch(components.NotificationList.prototype, 'im_livechat/static/src/components/
|
||||
*/
|
||||
_getThreads(props) {
|
||||
if (props.filter === 'livechat') {
|
||||
return this.env.models['mail.thread'].all(thread =>
|
||||
return this.messaging.models['mail.thread'].all(thread =>
|
||||
thread.channel_type === 'livechat' &&
|
||||
thread.isPinned &&
|
||||
thread.model === 'mail.channel'
|
||||
|
||||
+5
-4
@@ -17,23 +17,24 @@ const { onWillUpdateProps, useComponent } = owl.hooks;
|
||||
*/
|
||||
export function useComponentToModel({ fieldName, modelName, propNameAsRecordLocalId }) {
|
||||
const component = useComponent();
|
||||
const record = component.env.models[modelName].get(component.props[propNameAsRecordLocalId]);
|
||||
const { modelManager } = component.env.services.messaging;
|
||||
const record = modelManager.models[modelName].get(component.props[propNameAsRecordLocalId]);
|
||||
if (record) {
|
||||
record.update({ [fieldName]: component });
|
||||
}
|
||||
onWillUpdateProps(nextProps => {
|
||||
const currentRecord = component.env.models[modelName].get(component.props[propNameAsRecordLocalId]);
|
||||
const currentRecord = modelManager.models[modelName].get(component.props[propNameAsRecordLocalId]);
|
||||
if (currentRecord) {
|
||||
currentRecord.update({ [fieldName]: clear() });
|
||||
}
|
||||
const nextRecord = component.env.models[modelName].get(nextProps[propNameAsRecordLocalId]);
|
||||
const nextRecord = modelManager.models[modelName].get(nextProps[propNameAsRecordLocalId]);
|
||||
if (nextRecord) {
|
||||
nextRecord.update({ [fieldName]: component });
|
||||
}
|
||||
});
|
||||
const __destroy = component.__destroy;
|
||||
component.__destroy = parent => {
|
||||
const record = component.env.models[modelName].get(component.props[propNameAsRecordLocalId]);
|
||||
const record = modelManager.models[modelName].get(component.props[propNameAsRecordLocalId]);
|
||||
if (record) {
|
||||
record.update({ [fieldName]: clear() });
|
||||
}
|
||||
|
||||
@@ -18,24 +18,25 @@ const { onWillUpdateProps, useComponent, useRef } = owl.hooks;
|
||||
*/
|
||||
export function useRefToModel({ fieldName, modelName, propNameAsRecordLocalId, refName }) {
|
||||
const component = useComponent();
|
||||
const record = component.env.models[modelName].get(component.props[propNameAsRecordLocalId]);
|
||||
const { modelManager } = component.env.services.messaging;
|
||||
const record = modelManager.models[modelName].get(component.props[propNameAsRecordLocalId]);
|
||||
const ref = useRef(refName);
|
||||
if (record) {
|
||||
record.update({ [fieldName]: ref });
|
||||
}
|
||||
onWillUpdateProps(nextProps => {
|
||||
const currentRecord = component.env.models[modelName].get(component.props[propNameAsRecordLocalId]);
|
||||
const currentRecord = modelManager.models[modelName].get(component.props[propNameAsRecordLocalId]);
|
||||
if (currentRecord) {
|
||||
currentRecord.update({ [fieldName]: clear() });
|
||||
}
|
||||
const nextRecord = component.env.models[modelName].get(nextProps[propNameAsRecordLocalId]);
|
||||
const nextRecord = modelManager.models[modelName].get(nextProps[propNameAsRecordLocalId]);
|
||||
if (nextRecord) {
|
||||
nextRecord.update({ [fieldName]: ref });
|
||||
}
|
||||
});
|
||||
const __destroy = component.__destroy;
|
||||
component.__destroy = parent => {
|
||||
const record = component.env.models[modelName].get(component.props[propNameAsRecordLocalId]);
|
||||
const record = modelManager.models[modelName].get(component.props[propNameAsRecordLocalId]);
|
||||
if (record) {
|
||||
record.update({ [fieldName]: clear() });
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ const { useComponent } = owl.hooks;
|
||||
export function useUpdateToModel({ methodName, modelName, propNameAsRecordLocalId }) {
|
||||
const component = useComponent();
|
||||
useUpdate({ func: () => {
|
||||
const record = component.env.models[modelName].get(component.props[propNameAsRecordLocalId]);
|
||||
const record = component.env.services.messaging.modelManager.models[modelName].get(component.props[propNameAsRecordLocalId]);
|
||||
if (record) {
|
||||
record[methodName]();
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ export class Activity extends Component {
|
||||
* @returns {mail.activity}
|
||||
*/
|
||||
get activity() {
|
||||
return this.env.models['mail.activity'].get(this.props.activityLocalId);
|
||||
return this.messaging && this.messaging.models['mail.activity'].get(this.props.activityLocalId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -975,7 +975,7 @@ QUnit.test('activity click on cancel', async function (assert) {
|
||||
* @returns {mail.activity}
|
||||
*/
|
||||
get activity() {
|
||||
return this.env.models['mail.activity'].get(this.props.activityLocalId);
|
||||
return this.messaging.models['mail.activity'].get(this.props.activityLocalId);
|
||||
}
|
||||
}
|
||||
ParentComponent.env = this.env;
|
||||
|
||||
@@ -14,7 +14,7 @@ export class ActivityBox extends Component {
|
||||
* @returns {Chatter}
|
||||
*/
|
||||
get chatter() {
|
||||
return this.env.models['mail.chatter'].get(this.props.chatterLocalId);
|
||||
return this.messaging.models['mail.chatter'].get(this.props.chatterLocalId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ export class ActivityMarkDonePopover extends Component {
|
||||
* @returns {mail.activity}
|
||||
*/
|
||||
get activity() {
|
||||
return this.env.models['mail.activity'].get(this.props.activityLocalId);
|
||||
return this.messaging && this.messaging.models['mail.activity'].get(this.props.activityLocalId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,7 +24,7 @@ export class Attachment extends Component {
|
||||
* @returns {mail.attachment}
|
||||
*/
|
||||
get attachment() {
|
||||
return this.env.models['mail.attachment'].get(this.props.attachmentLocalId);
|
||||
return this.messaging && this.messaging.models['mail.attachment'].get(this.props.attachmentLocalId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,10 +115,10 @@ export class Attachment extends Component {
|
||||
if (!this.attachment.isViewable) {
|
||||
return;
|
||||
}
|
||||
this.env.models['mail.attachment'].view({
|
||||
this.messaging.models['mail.attachment'].view({
|
||||
attachment: this.attachment,
|
||||
attachments: this.props.attachmentLocalIds.map(
|
||||
attachmentLocalId => this.env.models['mail.attachment'].get(attachmentLocalId)
|
||||
attachmentLocalId => this.messaging.models['mail.attachment'].get(attachmentLocalId)
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ export class AttachmentBox extends Component {
|
||||
* @returns {mail.thread|undefined}
|
||||
*/
|
||||
get thread() {
|
||||
return this.env.models['mail.thread'].get(this.props.threadLocalId);
|
||||
return this.messaging && this.messaging.models['mail.thread'].get(this.props.threadLocalId);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ export class AttachmentDeleteConfirmDialog extends Component {
|
||||
* @returns {mail.attachment}
|
||||
*/
|
||||
get attachment() {
|
||||
return this.env.models['mail.attachment'].get(this.props.attachmentLocalId);
|
||||
return this.messaging && this.messaging.models['mail.attachment'].get(this.props.attachmentLocalId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,7 @@ export class AttachmentList extends Component {
|
||||
* @returns {mail.attachment[]}
|
||||
*/
|
||||
get attachments() {
|
||||
return this.env.models['mail.attachment'].all().filter(attachment =>
|
||||
return this.messaging && this.messaging.models['mail.attachment'].all().filter(attachment =>
|
||||
this.props.attachmentLocalIds.includes(attachment.localId)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ export class AttachmentViewer extends Component {
|
||||
* @returns {mail.attachment_viewer}
|
||||
*/
|
||||
get attachmentViewer() {
|
||||
return this.env.models['mail.attachment_viewer'].get(this.props.localId);
|
||||
return this.messaging && this.messaging.models['mail.attachment_viewer'].get(this.props.localId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ export class ChannelInvitationForm extends Component {
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
get channelInvitationForm() {
|
||||
return this.env.models['mail.channel_invitation_form'].get(this.props.localId);
|
||||
return this.messaging && this.messaging.models['mail.channel_invitation_form'].get(this.props.localId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ export class ChatWindow extends Component {
|
||||
* @returns {mail.chat_window}
|
||||
*/
|
||||
get chatWindow() {
|
||||
return this.env.models['mail.chat_window'].get(this.props.chatWindowLocalId);
|
||||
return this.messaging && this.messaging.models['mail.chat_window'].get(this.props.chatWindowLocalId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,7 +181,7 @@ export class ChatWindow extends Component {
|
||||
* @param {function} res
|
||||
*/
|
||||
_onAutocompleteSource(req, res) {
|
||||
this.env.models['mail.partner'].imSearch({
|
||||
this.messaging.models['mail.partner'].imSearch({
|
||||
callback: (partners) => {
|
||||
const suggestions = partners.map(partner => {
|
||||
return {
|
||||
|
||||
@@ -18,7 +18,7 @@ export class ChatWindowHeader extends Component {
|
||||
* @returns {mail.chat_window}
|
||||
*/
|
||||
get chatWindow() {
|
||||
return this.env.models['mail.chat_window'].get(this.props.chatWindowLocalId);
|
||||
return this.messaging && this.messaging.models['mail.chat_window'].get(this.props.chatWindowLocalId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,6 +45,9 @@ export class ChatWindowHiddenMenu extends Component {
|
||||
* @private
|
||||
*/
|
||||
_apply() {
|
||||
if (!this.messaging) {
|
||||
return;
|
||||
}
|
||||
this._applyListHeight();
|
||||
this._applyOffset();
|
||||
this._wasMenuOpen = this.env.messaging.chatWindowManager.isHiddenMenuOpen;
|
||||
|
||||
@@ -38,7 +38,7 @@ export class Chatter extends Component {
|
||||
* @returns {mail.chatter}
|
||||
*/
|
||||
get chatter() {
|
||||
return this.env.models['mail.chatter'].get(this.props.chatterLocalId);
|
||||
return this.messaging && this.messaging.models['mail.chatter'].get(this.props.chatterLocalId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,7 @@ export class ChatterTopbar extends Component {
|
||||
* @returns {mail.chatter}
|
||||
*/
|
||||
get chatter() {
|
||||
return this.env.models['mail.chatter'].get(this.props.chatterLocalId);
|
||||
return this.messaging && this.messaging.models['mail.chatter'].get(this.props.chatterLocalId);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
@@ -54,7 +54,7 @@ export class Composer extends Component {
|
||||
* @returns {mail.composer}
|
||||
*/
|
||||
get composer() {
|
||||
return this.env.models['mail.composer'].get(this.props.composerLocalId);
|
||||
return this.messaging && this.messaging.models['mail.composer'].get(this.props.composerLocalId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ export class ComposerSuggestedRecipient extends Component {
|
||||
* @returns {mail.suggested_recipient_info}
|
||||
*/
|
||||
get suggestedRecipientInfo() {
|
||||
return this.env.models['mail.suggested_recipient_info'].get(this.props.suggestedRecipientInfoLocalId);
|
||||
return this.messaging && this.messaging.models['mail.suggested_recipient_info'].get(this.props.suggestedRecipientInfoLocalId);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ export class ComposerSuggestedRecipientList extends Component {
|
||||
* @returns {mail.thread}
|
||||
*/
|
||||
get thread() {
|
||||
return this.env.models['mail.thread'].get(this.props.threadLocalId);
|
||||
return this.messaging && this.messaging.models['mail.thread'].get(this.props.threadLocalId);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
@@ -24,7 +24,7 @@ export class ComposerSuggestion extends Component {
|
||||
* @returns {mail.composer}
|
||||
*/
|
||||
get composer() {
|
||||
return this.env.models['mail.composer'].get(this.props.composerLocalId);
|
||||
return this.messaging && this.messaging.models['mail.composer'].get(this.props.composerLocalId);
|
||||
}
|
||||
|
||||
get isCannedResponse() {
|
||||
@@ -44,7 +44,7 @@ export class ComposerSuggestion extends Component {
|
||||
}
|
||||
|
||||
get record() {
|
||||
return this.env.models[this.props.modelName].get(this.props.recordLocalId);
|
||||
return this.messaging && this.messaging.models[this.props.modelName].get(this.props.recordLocalId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ export class ComposerSuggestionList extends Component {
|
||||
* @returns {mail.composer}
|
||||
*/
|
||||
get composer() {
|
||||
return this.env.models['mail.composer'].get(this.props.composerLocalId);
|
||||
return this.messaging && this.messaging.models['mail.composer'].get(this.props.composerLocalId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ export class ComposerTextInput extends Component {
|
||||
* @returns {mail.composer}
|
||||
*/
|
||||
get composer() {
|
||||
return this.env.models['mail.composer'].get(this.props.composerLocalId);
|
||||
return this.messaging && this.messaging.models['mail.composer'].get(this.props.composerLocalId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -44,7 +44,7 @@ export class Dialog extends Component {
|
||||
* @returns {mail.dialog}
|
||||
*/
|
||||
get dialog() {
|
||||
return this.env.models['mail.dialog'].get(this.props.dialogLocalId);
|
||||
return this.messaging && this.messaging.models['mail.dialog'].get(this.props.dialogLocalId);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
@@ -27,6 +27,9 @@ export class Discuss extends Component {
|
||||
}
|
||||
|
||||
mounted() {
|
||||
if (!this.discuss) {
|
||||
return;
|
||||
}
|
||||
this.discuss.update({ isOpen: true });
|
||||
if (this.discuss.thread) {
|
||||
this.trigger('o-push-state-action-manager');
|
||||
@@ -114,6 +117,9 @@ export class Discuss extends Component {
|
||||
* @private
|
||||
*/
|
||||
_updateLocalStoreProps() {
|
||||
if (!this.discuss) {
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Locally tracked store props `activeThreadCache`.
|
||||
* Useful to set scroll position from last stored one and to display
|
||||
|
||||
@@ -38,6 +38,18 @@ QUnit.module('discuss_tests.js', {
|
||||
},
|
||||
});
|
||||
|
||||
QUnit.test('messaging not created', async function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
const messagingBeforeCreationDeferred = makeTestPromise();
|
||||
await this.start({
|
||||
messagingBeforeCreationDeferred,
|
||||
waitUntilMessagingCondition: 'none'
|
||||
});
|
||||
assert.containsOnce(document.body, '.o_Discuss_messagingNotInitialized', "should display messaging not initialized");
|
||||
messagingBeforeCreationDeferred.resolve();
|
||||
});
|
||||
|
||||
QUnit.test('messaging not initialized', async function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
|
||||
+5
-2
@@ -14,7 +14,10 @@ export class DiscussMobileMailboxSelection extends Component {
|
||||
* @returns {mail.thread[]}
|
||||
*/
|
||||
get orderedMailboxes() {
|
||||
return this.env.models['mail.thread']
|
||||
if (!this.messaging) {
|
||||
return [];
|
||||
}
|
||||
return this.messaging.models['mail.thread']
|
||||
.all(thread => thread.isPinned && thread.model === 'mail.box')
|
||||
.sort((mailbox1, mailbox2) => {
|
||||
if (mailbox1 === this.discuss.messaging.inbox) {
|
||||
@@ -54,7 +57,7 @@ export class DiscussMobileMailboxSelection extends Component {
|
||||
*/
|
||||
_onClick(ev) {
|
||||
const { mailboxLocalId } = ev.currentTarget.dataset;
|
||||
const mailbox = this.env.models['mail.thread'].get(mailboxLocalId);
|
||||
const mailbox = this.messaging.models['mail.thread'].get(mailboxLocalId);
|
||||
if (!mailbox) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ export class DiscussSidebar extends Component {
|
||||
* @returns {mail.thread[]}
|
||||
*/
|
||||
get orderedMailboxes() {
|
||||
return this.env.models['mail.thread']
|
||||
return this.messaging.models['mail.thread']
|
||||
.all(thread => thread.isPinned && thread.model === 'mail.box')
|
||||
.sort((mailbox1, mailbox2) => {
|
||||
if (mailbox1 === this.discuss.messaging.inbox) {
|
||||
@@ -76,7 +76,7 @@ export class DiscussSidebar extends Component {
|
||||
* @returns {mail.thread[]}
|
||||
*/
|
||||
get quickSearchPinnedAndOrderedChats() {
|
||||
const allOrderedAndPinnedChats = this.env.models['mail.thread']
|
||||
const allOrderedAndPinnedChats = this.messaging.models['mail.thread']
|
||||
.all(thread =>
|
||||
thread.channel_type === 'chat' &&
|
||||
thread.isPinned &&
|
||||
@@ -99,7 +99,7 @@ export class DiscussSidebar extends Component {
|
||||
* @returns {mail.thread[]}
|
||||
*/
|
||||
get quickSearchOrderedAndPinnedMultiUserChannels() {
|
||||
const allOrderedAndPinnedMultiUserChannels = this.env.models['mail.thread']
|
||||
const allOrderedAndPinnedMultiUserChannels = this.messaging.models['mail.thread']
|
||||
.all(thread =>
|
||||
thread.channel_type === 'channel' &&
|
||||
thread.isPinned &&
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
</t>
|
||||
</div>
|
||||
<hr class="o_DiscussSidebar_separator"/>
|
||||
<t t-if="env.models['mail.thread'].all(thread => thread.isPinned and thread.model === 'mail.channel').length > 19">
|
||||
<t t-if="messaging.models['mail.thread'].all(thread => thread.isPinned and thread.model === 'mail.channel').length > 19">
|
||||
<input class="o_DiscussSidebar_quickSearch" t-on-input="_onInputQuickSearch" placeholder="Quick search..." t-ref="quickSearchInput" t-esc="discuss.sidebarQuickSearchValue"/>
|
||||
</t>
|
||||
<div class="o_DiscussSidebar_group o_DiscussSidebar_groupChannel">
|
||||
|
||||
@@ -47,7 +47,7 @@ export class DiscussSidebarItem extends Component {
|
||||
* @returns {mail.thread}
|
||||
*/
|
||||
get thread() {
|
||||
return this.env.models['mail.thread'].get(this.props.threadLocalId);
|
||||
return this.messaging && this.messaging.models['mail.thread'].get(this.props.threadLocalId);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
@@ -57,7 +57,7 @@ export class FileUploader extends Component {
|
||||
* @returns {mail.attachment}
|
||||
*/
|
||||
_createAttachment(fileData) {
|
||||
return this.env.models['mail.attachment'].create(Object.assign(
|
||||
return this.messaging.models['mail.attachment'].create(Object.assign(
|
||||
{},
|
||||
fileData,
|
||||
this.props.newAttachmentExtraData
|
||||
@@ -85,7 +85,7 @@ export class FileUploader extends Component {
|
||||
*/
|
||||
_createUploadingAttachments(files) {
|
||||
for (const file of files) {
|
||||
this.env.models['mail.attachment'].create(
|
||||
this.messaging.models['mail.attachment'].create(
|
||||
Object.assign(
|
||||
{
|
||||
filename: file.name,
|
||||
@@ -104,7 +104,7 @@ export class FileUploader extends Component {
|
||||
*/
|
||||
async _performUpload(files) {
|
||||
for (const file of files) {
|
||||
const uploadingAttachment = this.env.models['mail.attachment'].find(attachment =>
|
||||
const uploadingAttachment = this.messaging.models['mail.attachment'].find(attachment =>
|
||||
attachment.isUploading &&
|
||||
attachment.filename === file.name
|
||||
);
|
||||
@@ -139,7 +139,7 @@ export class FileUploader extends Component {
|
||||
async _unlinkExistingAttachments(files) {
|
||||
for (const file of files) {
|
||||
const attachment = this.props.attachmentLocalIds
|
||||
.map(attachmentLocalId => this.env.models['mail.attachment'].get(attachmentLocalId))
|
||||
.map(attachmentLocalId => this.messaging.models['mail.attachment'].get(attachmentLocalId))
|
||||
.find(attachment => attachment.name === file.name && attachment.size === file.size);
|
||||
// if the files already exits, delete the file before upload
|
||||
if (attachment) {
|
||||
@@ -165,7 +165,7 @@ export class FileUploader extends Component {
|
||||
type: 'danger',
|
||||
message: error,
|
||||
});
|
||||
const relatedUploadingAttachments = this.env.models['mail.attachment']
|
||||
const relatedUploadingAttachments = this.messaging.models['mail.attachment']
|
||||
.find(attachment =>
|
||||
attachment.filename === filename &&
|
||||
attachment.isUploading
|
||||
@@ -175,7 +175,7 @@ export class FileUploader extends Component {
|
||||
}
|
||||
return;
|
||||
}
|
||||
const attachment = this.env.models['mail.attachment'].insert(
|
||||
const attachment = this.messaging.models['mail.attachment'].insert(
|
||||
Object.assign(
|
||||
{
|
||||
filename,
|
||||
|
||||
@@ -27,7 +27,7 @@ export class FollowButton extends Component {
|
||||
* @return {mail.thread}
|
||||
*/
|
||||
get thread() {
|
||||
return this.env.models['mail.thread'].get(this.props.threadLocalId);
|
||||
return this.messaging && this.messaging.models['mail.thread'].get(this.props.threadLocalId);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
@@ -14,7 +14,7 @@ export class Follower extends Component {
|
||||
* @returns {mail.follower}
|
||||
*/
|
||||
get follower() {
|
||||
return this.env.models['mail.follower'].get(this.props.followerLocalId);
|
||||
return this.messaging && this.messaging.models['mail.follower'].get(this.props.followerLocalId);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
@@ -37,7 +37,7 @@ export class FollowerListMenu extends Component {
|
||||
* @return {mail.thread}
|
||||
*/
|
||||
get thread() {
|
||||
return this.env.models['mail.thread'].get(this.props.threadLocalId);
|
||||
return this.messaging && this.messaging.models['mail.thread'].get(this.props.threadLocalId);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
@@ -14,14 +14,14 @@ export class FollowerSubtype extends Component {
|
||||
* @returns {mail.follower|undefined}
|
||||
*/
|
||||
get follower() {
|
||||
return this.env.models['mail.follower'].get(this.props.followerLocalId);
|
||||
return this.messaging && this.messaging.models['mail.follower'].get(this.props.followerLocalId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {mail.follower_subtype}
|
||||
*/
|
||||
get followerSubtype() {
|
||||
return this.env.models['mail.follower_subtype'].get(this.props.followerSubtypeLocalId);
|
||||
return this.messaging && this.messaging.models['mail.follower_subtype'].get(this.props.followerSubtypeLocalId);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
@@ -14,7 +14,7 @@ export class FollowerSubtypeList extends Component {
|
||||
* @returns {mail.follower_subtype_list}
|
||||
*/
|
||||
get followerSubtypeList() {
|
||||
return this.env.models['mail.follower_subtype_list'].get(this.props.localId);
|
||||
return this.messaging && this.messaging.models['mail.follower_subtype_list'].get(this.props.localId);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
@@ -14,14 +14,14 @@ export class MailTemplate extends Component {
|
||||
* @returns {mail.activity}
|
||||
*/
|
||||
get activity() {
|
||||
return this.env.models['mail.activity'].get(this.props.activityLocalId);
|
||||
return this.messaging && this.messaging.models['mail.activity'].get(this.props.activityLocalId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {mail.mail_template}
|
||||
*/
|
||||
get mailTemplate() {
|
||||
return this.env.models['mail.mail_template'].get(this.props.mailTemplateLocalId);
|
||||
return this.messaging && this.messaging.models['mail.mail_template'].get(this.props.mailTemplateLocalId);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
@@ -173,7 +173,7 @@ export class Message extends Component {
|
||||
* @returns {mail.message}
|
||||
*/
|
||||
get message() {
|
||||
return this.env.models['mail.message'].get(this.props.messageLocalId);
|
||||
return this.messaging && this.messaging.models['mail.message'].get(this.props.messageLocalId);
|
||||
}
|
||||
/**
|
||||
* @returns {string}
|
||||
@@ -217,7 +217,7 @@ export class Message extends Component {
|
||||
* @returns {mail.thread_view}
|
||||
*/
|
||||
get threadView() {
|
||||
return this.env.models['mail.thread_view'].get(this.props.threadViewLocalId);
|
||||
return this.messaging && this.messaging.models['mail.thread_view'].get(this.props.threadViewLocalId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,14 +14,14 @@ export class MessageAuthorPrefix extends Component {
|
||||
* @returns {mail.message}
|
||||
*/
|
||||
get message() {
|
||||
return this.env.models['mail.message'].get(this.props.messageLocalId);
|
||||
return this.messaging && this.messaging.models['mail.message'].get(this.props.messageLocalId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {mail.thread|undefined}
|
||||
*/
|
||||
get thread() {
|
||||
return this.env.models['mail.thread'].get(this.props.threadLocalId);
|
||||
return this.messaging && this.messaging.models['mail.thread'].get(this.props.threadLocalId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ export class MessageList extends Component {
|
||||
.filter(([refId, ref]) => (
|
||||
// Message refs have message local id as ref id, and message
|
||||
// local ids contain name of model 'mail.message'.
|
||||
refId.includes(this.env.models['mail.message'].modelName) &&
|
||||
refId.includes(this.messaging.models['mail.message'].modelName) &&
|
||||
// Component that should be destroyed but haven't just yet.
|
||||
ref.message
|
||||
)
|
||||
@@ -308,7 +308,7 @@ export class MessageList extends Component {
|
||||
* @returns {mail.thread_view}
|
||||
*/
|
||||
get threadView() {
|
||||
return this.env.models['mail.thread_view'].get(this.props.threadViewLocalId);
|
||||
return this.messaging && this.messaging.models['mail.thread_view'].get(this.props.threadViewLocalId);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
@@ -76,7 +76,7 @@ export class MessageSeenIndicator extends Component {
|
||||
* @returns {mail.message}
|
||||
*/
|
||||
get message() {
|
||||
return this.env.models['mail.message'].get(this.props.messageLocalId);
|
||||
return this.messaging && this.messaging.models['mail.message'].get(this.props.messageLocalId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,7 +86,7 @@ export class MessageSeenIndicator extends Component {
|
||||
if (!this.thread || this.thread.model !== 'mail.channel') {
|
||||
return undefined;
|
||||
}
|
||||
return this.env.models['mail.message_seen_indicator'].findFromIdentifyingData({
|
||||
return this.messaging.models['mail.message_seen_indicator'].findFromIdentifyingData({
|
||||
channelId: this.thread.id,
|
||||
messageId: this.message.id,
|
||||
});
|
||||
@@ -96,7 +96,7 @@ export class MessageSeenIndicator extends Component {
|
||||
* @returns {mail.Thread}
|
||||
*/
|
||||
get thread() {
|
||||
return this.env.models['mail.thread'].get(this.props.threadLocalId);
|
||||
return this.messaging && this.messaging.models['mail.thread'].get(this.props.threadLocalId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ export class MessagingMenu extends Component {
|
||||
*/
|
||||
_onMobileNewMessageInputSource(req, res) {
|
||||
const value = _.escape(req.term);
|
||||
this.env.models['mail.partner'].imSearch({
|
||||
this.messaging.models['mail.partner'].imSearch({
|
||||
callback: partners => {
|
||||
const suggestions = partners.map(partner => {
|
||||
return {
|
||||
|
||||
@@ -27,7 +27,7 @@ export class NotificationGroup extends Component {
|
||||
* @returns {mail.notification_group}
|
||||
*/
|
||||
get group() {
|
||||
return this.env.models['mail.notification_group'].get(this.props.notificationGroupLocalId);
|
||||
return this.messaging && this.messaging.models['mail.notification_group'].get(this.props.notificationGroupLocalId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,11 +18,14 @@ export class NotificationList extends Component {
|
||||
* @returns {Object[]}
|
||||
*/
|
||||
get notifications() {
|
||||
if (!this.messaging) {
|
||||
return [];
|
||||
}
|
||||
const threads = this._getThreads(this.props);
|
||||
let threadNeedactionNotifications = [];
|
||||
if (this.props.filter === 'all') {
|
||||
// threads with needactions
|
||||
threadNeedactionNotifications = this.env.models['mail.thread']
|
||||
threadNeedactionNotifications = this.messaging.models['mail.thread']
|
||||
.all(t => t.model !== 'mail.box' && t.needactionMessagesAsOriginThread.length > 0)
|
||||
.sort((t1, t2) => {
|
||||
if (t1.needactionMessagesAsOriginThread.length > 0 && t2.needactionMessagesAsOriginThread.length === 0) {
|
||||
@@ -113,7 +116,7 @@ export class NotificationList extends Component {
|
||||
const threads = this.notifications
|
||||
.filter(notification => notification.thread && notification.thread.exists())
|
||||
.map(notification => notification.thread);
|
||||
this.env.models['mail.thread'].loadPreviews(threads);
|
||||
this.messaging.models['mail.thread'].loadPreviews(threads);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,7 +127,7 @@ export class NotificationList extends Component {
|
||||
*/
|
||||
_getThreads(props) {
|
||||
if (props.filter === 'mailbox') {
|
||||
return this.env.models['mail.thread']
|
||||
return this.messaging.models['mail.thread']
|
||||
.all(thread => thread.isPinned && thread.model === 'mail.box')
|
||||
.sort((mailbox1, mailbox2) => {
|
||||
if (mailbox1 === this.env.messaging.inbox) {
|
||||
@@ -144,7 +147,7 @@ export class NotificationList extends Component {
|
||||
mailbox1Name < mailbox2Name ? -1 : 1;
|
||||
});
|
||||
} else if (props.filter === 'channel') {
|
||||
return this.env.models['mail.thread']
|
||||
return this.messaging.models['mail.thread']
|
||||
.all(thread =>
|
||||
thread.channel_type === 'channel' &&
|
||||
thread.isPinned &&
|
||||
@@ -152,7 +155,7 @@ export class NotificationList extends Component {
|
||||
)
|
||||
.sort((c1, c2) => c1.displayName < c2.displayName ? -1 : 1);
|
||||
} else if (props.filter === 'chat') {
|
||||
return this.env.models['mail.thread']
|
||||
return this.messaging.models['mail.thread']
|
||||
.all(thread =>
|
||||
thread.isChatChannel &&
|
||||
thread.isPinned &&
|
||||
@@ -161,7 +164,7 @@ export class NotificationList extends Component {
|
||||
.sort((c1, c2) => c1.displayName < c2.displayName ? -1 : 1);
|
||||
} else if (props.filter === 'all') {
|
||||
// "All" filter is for channels and chats
|
||||
return this.env.models['mail.thread']
|
||||
return this.messaging.models['mail.thread']
|
||||
.all(thread => thread.isPinned && thread.model === 'mail.channel')
|
||||
.sort((c1, c2) => c1.displayName < c2.displayName ? -1 : 1);
|
||||
} else {
|
||||
|
||||
@@ -48,8 +48,11 @@ export class NotificationPopover extends Component {
|
||||
* @returns {mail.notification[]}
|
||||
*/
|
||||
get notifications() {
|
||||
if (!this.messaging) {
|
||||
return [];
|
||||
}
|
||||
return this.props.notificationLocalIds.map(
|
||||
notificationLocalId => this.env.models['mail.notification'].get(notificationLocalId)
|
||||
notificationLocalId => this.messaging.models['mail.notification'].get(notificationLocalId)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ export class PartnerImStatusIcon extends Component {
|
||||
* @returns {mail.partner}
|
||||
*/
|
||||
get partner() {
|
||||
return this.env.models['mail.partner'].get(this.props.partnerLocalId);
|
||||
return this.messaging && this.messaging.models['mail.partner'].get(this.props.partnerLocalId);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
@@ -14,7 +14,7 @@ export class ThreadIcon extends Component {
|
||||
* @returns {mail.thread}
|
||||
*/
|
||||
get thread() {
|
||||
return this.env.models['mail.thread'].get(this.props.threadLocalId);
|
||||
return this.messaging && this.messaging.models['mail.thread'].get(this.props.threadLocalId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -59,7 +59,7 @@ export class ThreadNeedactionPreview extends Component {
|
||||
* @returns {mail.thread}
|
||||
*/
|
||||
get thread() {
|
||||
return this.env.models['mail.thread'].get(this.props.threadLocalId);
|
||||
return this.messaging && this.messaging.models['mail.thread'].get(this.props.threadLocalId);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -87,7 +87,7 @@ export class ThreadNeedactionPreview extends Component {
|
||||
* @param {MouseEvent} ev
|
||||
*/
|
||||
_onClickMarkAsRead(ev) {
|
||||
this.env.models['mail.message'].markAllAsRead([
|
||||
this.messaging.models['mail.message'].markAllAsRead([
|
||||
['model', '=', this.thread.model],
|
||||
['res_id', '=', this.thread.id],
|
||||
]);
|
||||
|
||||
@@ -53,7 +53,7 @@ export class ThreadPreview extends Component {
|
||||
* @returns {mail.thread}
|
||||
*/
|
||||
get thread() {
|
||||
return this.env.models['mail.thread'].get(this.props.threadLocalId);
|
||||
return this.messaging && this.messaging.models['mail.thread'].get(this.props.threadLocalId);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ export class ThreadTextualTypingStatus extends Component {
|
||||
* @returns {mail.thread}
|
||||
*/
|
||||
get thread() {
|
||||
return this.env.models['mail.thread'].get(this.props.threadLocalId);
|
||||
return this.messaging && this.messaging.models['mail.thread'].get(this.props.threadLocalId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ export class ThreadView extends Component {
|
||||
* @returns {mail.thread_view}
|
||||
*/
|
||||
get threadView() {
|
||||
return this.env.models['mail.thread_view'].get(this.props.threadViewLocalId);
|
||||
return this.messaging && this.messaging.models['mail.thread_view'].get(this.props.threadViewLocalId);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
@@ -25,7 +25,7 @@ export class ThreadViewTopbar extends Component {
|
||||
* @returns {mail.thread_view_topbar}
|
||||
*/
|
||||
get threadViewTopBar() {
|
||||
return this.env.models['mail.thread_view_topbar'].get(this.props.localId);
|
||||
return this.messaging && this.messaging.models['mail.thread_view_topbar'].get(this.props.localId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,10 +21,5 @@ Object.defineProperty(env, 'messaging', {
|
||||
return this.services.messaging.modelManager.messaging;
|
||||
},
|
||||
});
|
||||
Object.defineProperty(env, 'models', {
|
||||
get() {
|
||||
return this.services.messaging.modelManager.models;
|
||||
},
|
||||
});
|
||||
|
||||
serviceRegistry.add('messaging', MessagingService);
|
||||
|
||||
@@ -25,7 +25,7 @@ export function registerMessagingComponent(ComponentClass, { propsCompareDepth =
|
||||
const decoratedName = `@messaging ${name}`;
|
||||
// Defining the class in an object and immediately taking it out so that it
|
||||
// has "decoratedName" as its class name in stack traces and stuff.
|
||||
const MessagingClass = {[decoratedName]: class extends ComponentClass {
|
||||
const MessagingClass = { [decoratedName]: class extends ComponentClass {
|
||||
setup(...args) {
|
||||
super.setup(...args);
|
||||
// useModels must be defined after useRenderedValues, indeed records and
|
||||
@@ -34,7 +34,10 @@ export function registerMessagingComponent(ComponentClass, { propsCompareDepth =
|
||||
useModels();
|
||||
useShouldUpdateBasedOnProps({ propsCompareDepth });
|
||||
}
|
||||
}}[decoratedName];
|
||||
get messaging() {
|
||||
return this.env.services.messaging.modelManager.messaging;
|
||||
}
|
||||
} }[decoratedName];
|
||||
// Create an object whose prototype is the component registry with the values of the original
|
||||
// Component.components. This means that trying to get a value from this object will first look
|
||||
// into the original Component's components, and fall back on the registry if not found.
|
||||
|
||||
@@ -555,11 +555,6 @@ async function start(param0 = {}) {
|
||||
return this.services.messaging.modelManager.messaging;
|
||||
},
|
||||
});
|
||||
Object.defineProperty(env, 'models', {
|
||||
get() {
|
||||
return this.services.messaging.modelManager.models;
|
||||
},
|
||||
});
|
||||
this._super(env);
|
||||
},
|
||||
/**
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ class SnailmailErrorDialog extends Component {
|
||||
* @returns {mail.message}
|
||||
*/
|
||||
get message() {
|
||||
return this.env.models['mail.message'].get(this.props.messageLocalId);
|
||||
return this.messaging && this.messaging.models['mail.message'].get(this.props.messageLocalId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ class SnailmailNotificationPopover extends Component {
|
||||
* @returns {mail.message}
|
||||
*/
|
||||
get message() {
|
||||
return this.env.models['mail.message'].get(this.props.messageLocalId);
|
||||
return this.messaging && this.messaging.models['mail.message'].get(this.props.messageLocalId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,7 +15,7 @@ class VisitorBanner extends Component {
|
||||
* @returns {website_livechat.visitor}
|
||||
*/
|
||||
get visitor() {
|
||||
return this.env.models['website_livechat.visitor'].get(this.props.visitorLocalId);
|
||||
return this.messaging && this.messaging.models['website_livechat.visitor'].get(this.props.visitorLocalId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user