[IMP] mail, *: access messaging without env in most components

* = snailmail

Part of task-2582313

closes odoo/odoo#75268

Related: odoo/enterprise#20333
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
Sébastien Theys
2021-08-18 16:29:49 +00:00
parent 166999e725
commit f8a7c8d31d
32 changed files with 123 additions and 134 deletions
@@ -123,7 +123,7 @@ export class Activity extends Component {
ev.target.dataset.oeId &&
ev.target.dataset.oeModel
) {
this.env.messaging.openProfile({
this.activity.messaging.openProfile({
id: Number(ev.target.dataset.oeId),
model: ev.target.dataset.oeModel,
});
@@ -26,8 +26,8 @@
</div>
<div class="o-autogrow"/>
<div class="o_AttachmentViewer_buttonDownload o_AttachmentViewer_headerItem o_AttachmentViewer_headerItemButton" t-on-click="_onClickDownload" role="button" title="Download">
<i class="o_AttachmentViewer_headerItemButtonIcon fa fa-download fa-fw" t-att-class="{ 'o-hasLabel': env.messaging.device.sizeClass > env.device.SIZES.MD }" role="img"/>
<t t-if="env.messaging.device.sizeClass > env.device.SIZES.MD">
<i class="o_AttachmentViewer_headerItemButtonIcon fa fa-download fa-fw" t-att-class="{ 'o-hasLabel': attachmentViewer.messaging.device.sizeClass > env.device.SIZES.MD }" role="img"/>
<t t-if="attachmentViewer.messaging.device.sizeClass > env.device.SIZES.MD">
<span>Download</span>
</t>
</div>
@@ -47,7 +47,7 @@
</div>
</t>
<t t-if="attachmentViewer.attachment.fileType === 'application/pdf'">
<iframe class="o_AttachmentViewer_view o_AttachmentViewer_viewIframe o_AttachmentViewer_viewPdf" t-ref="iframeViewerPdf" t-att-class="{ 'o-isMobile': env.messaging.device.isMobile }" t-att-src="attachmentViewer.attachment.defaultSource"/>
<iframe class="o_AttachmentViewer_view o_AttachmentViewer_viewIframe o_AttachmentViewer_viewPdf" t-ref="iframeViewerPdf" t-att-class="{ 'o-isMobile': attachmentViewer.messaging.device.isMobile }" t-att-src="attachmentViewer.attachment.defaultSource"/>
</t>
<t t-if="attachmentViewer.attachment.isTextFile">
<iframe class="o_AttachmentViewer_view o_AttachmentViewer_viewIframe o_text" t-att-src="attachmentViewer.attachment.defaultSource"/>
@@ -56,7 +56,7 @@
<iframe allow="autoplay; encrypted-media" class="o_AttachmentViewer_view o_AttachmentViewer_viewIframe o_AttachmentViewer_youtube" t-att-src="attachmentViewer.attachment.defaultSource" height="315" width="560"/>
</t>
<t t-if="attachmentViewer.attachment.fileType === 'video'">
<video class="o_AttachmentViewer_view o_AttachmentViewer_viewVideo" t-att-class="{ 'o-isMobile': env.messaging.device.isMobile }" t-on-click="_onClickVideo" controls="controls">
<video class="o_AttachmentViewer_view o_AttachmentViewer_viewVideo" t-att-class="{ 'o-isMobile': attachmentViewer.messaging.device.isMobile }" t-on-click="_onClickVideo" controls="controls">
<source t-att-data-type="attachmentViewer.attachment.mimetype" t-att-src="attachmentViewer.attachment.defaultSource"/>
</video>
</t>
@@ -16,7 +16,7 @@
<PartnerImStatusIcon
class="o_ChannelInvitationForm_selectablePartnerImStatusIcon d-flex align-items-center justify-content-center text-white"
t-att-class="{
'o_ChannelInvitationForm_selectablePartnerImStatusIcon-mobile': env.messaging.device.isMobile,
'o_ChannelInvitationForm_selectablePartnerImStatusIcon-mobile': selectablePartner.messaging.device.isMobile,
}"
partnerLocalId="selectablePartner.localId"
/>
@@ -75,7 +75,7 @@ export class ChatWindow extends Component {
* @private
*/
_applyVisibleOffset() {
const textDirection = this.env.messaging.locale.textDirection;
const textDirection = this.chatWindow.messaging.locale.textDirection;
const offsetFrom = textDirection === 'rtl' ? 'left' : 'right';
const oppositeFrom = offsetFrom === 'right' ? 'left' : 'right';
this.el.style[offsetFrom] = this.chatWindow.visibleOffset + 'px';
@@ -161,11 +161,11 @@ export class ChatWindow extends Component {
* @param {integer} ui.item.id
*/
async _onAutocompleteSelect(ev, ui) {
const chat = await this.env.messaging.getChat({ partnerId: ui.item.id });
const chat = await this.chatWindow.messaging.getChat({ partnerId: ui.item.id });
if (!chat) {
return;
}
this.env.messaging.chatWindowManager.openThread(chat, {
this.chatWindow.messaging.chatWindowManager.openThread(chat, {
makeActive: true,
replaceNewMessage: true,
});
@@ -206,7 +206,7 @@ export class ChatWindow extends Component {
*/
_onClickedHeader(ev) {
ev.stopPropagation();
if (this.env.messaging.device.isMobile) {
if (this.chatWindow.messaging.device.isMobile) {
return;
}
if (this.chatWindow.isFolded) {
@@ -7,7 +7,7 @@
'o-focused': chatWindow and chatWindow.isFocused,
'o-folded': chatWindow and chatWindow.isFolded,
'o-fullscreen': props.isFullscreen,
'o-mobile': env.messaging.device.isMobile,
'o-mobile': chatWindow and chatWindow.messaging.device.isMobile,
'o-new-message': chatWindow and !chatWindow.thread,
}" t-on-keydown="_onKeydown" t-on-focusout="_onFocusout" t-att-data-chat-window-local-id="chatWindow ? chatWindow.localId : undefined" t-att-data-thread-local-id="chatWindow ? (chatWindow.thread ? chatWindow.thread.localId : '') : undefined"
>
@@ -26,7 +26,7 @@
composerAttachmentsDetailsMode="'card'"
hasComposer="chatWindow.thread.model !== 'mail.box'"
hasComposerCurrentPartnerAvatar="false"
hasComposerSendButton="env.messaging.device.isMobile"
hasComposerSendButton="chatWindow.messaging.device.isMobile"
hasSquashCloseMessages="chatWindow.thread.model !== 'mail.box'"
threadViewLocalId="chatWindow.threadView.localId"
t-on-focusin="_onFocusinThread"
@@ -25,7 +25,7 @@ export class ChatWindowHeader extends Component {
* @returns {string}
*/
get shiftNextText() {
if (this.env.messaging.locale.textDirection === 'rtl') {
if (this.chatWindow.messaging.locale.textDirection === 'rtl') {
return this.env._t("Shift left");
}
return this.env._t("Shift right");
@@ -35,7 +35,7 @@ export class ChatWindowHeader extends Component {
* @returns {string}
*/
get shiftPrevText() {
if (this.env.messaging.locale.textDirection === 'rtl') {
if (this.chatWindow.messaging.locale.textDirection === 'rtl') {
return this.env._t("Shift right");
}
return this.env._t("Shift left");
@@ -2,10 +2,10 @@
<templates xml:space="preserve">
<t t-name="mail.ChatWindowHeader" owl="1">
<div class="o_ChatWindowHeader" t-att-class="{ 'o-mobile': env.messaging.device.isMobile }" t-on-click="_onClick">
<div class="o_ChatWindowHeader" t-att-class="{ 'o-mobile': chatWindow and chatWindow.messaging.device.isMobile }" t-on-click="_onClick">
<t t-if="chatWindow">
<t t-if="props.hasCloseAsBackButton">
<div class="o_ChatWindowHeader_command o_ChatWindowHeader_commandBack o_ChatWindowHeader_commandClose" t-att-class="{ 'o-mobile': env.messaging.device.isMobile }" t-on-click="_onClickClose" title="Close conversation">
<div class="o_ChatWindowHeader_command o_ChatWindowHeader_commandBack o_ChatWindowHeader_commandClose" t-att-class="{ 'o-mobile': chatWindow.messaging.device.isMobile }" t-on-click="_onClickClose" title="Close conversation">
<i class="fa fa-arrow-left"/>
</div>
</t>
@@ -26,24 +26,24 @@
<div class="o-autogrow"/>
<div class="o_ChatWindowHeader_item o_ChatWindowHeader_rightArea">
<t t-if="chatWindow.hasShiftPrev">
<div class="o_ChatWindowHeader_command o_ChatWindowHeader_commandShiftPrev" t-att-class="{ 'o-mobile': env.messaging.device.isMobile }" t-on-click="_onClickShiftPrev" t-att-title="shiftPrevText">
<div class="o_ChatWindowHeader_command o_ChatWindowHeader_commandShiftPrev" t-att-class="{ 'o-mobile': chatWindow.messaging.device.isMobile }" t-on-click="_onClickShiftPrev" t-att-title="shiftPrevText">
<!-- this is reversed automatically when language is rtl -->
<i class="fa fa-angle-left"/>
</div>
</t>
<t t-if="chatWindow.hasShiftNext">
<div class="o_ChatWindowHeader_command o_ChatWindowHeader_commandShiftNext" t-att-class="{ 'o-mobile': env.messaging.device.isMobile }" t-on-click="_onClickShiftNext" t-att-title="shiftNextText">
<div class="o_ChatWindowHeader_command o_ChatWindowHeader_commandShiftNext" t-att-class="{ 'o-mobile': chatWindow.messaging.device.isMobile }" t-on-click="_onClickShiftNext" t-att-title="shiftNextText">
<!-- this is reversed automatically when language is rtl -->
<i class="fa fa-angle-right"/>
</div>
</t>
<t t-if="props.isExpandable">
<div class="o_ChatWindowHeader_command o_ChatWindowHeader_commandExpand" t-att-class="{ 'o-mobile': env.messaging.device.isMobile }" t-on-click="_onClickExpand" title="Open in Discuss">
<div class="o_ChatWindowHeader_command o_ChatWindowHeader_commandExpand" t-att-class="{ 'o-mobile': chatWindow.messaging.device.isMobile }" t-on-click="_onClickExpand" title="Open in Discuss">
<i class="fa fa-expand"/>
</div>
</t>
<t t-if="!props.hasCloseAsBackButton">
<div class="o_ChatWindowHeader_command o_ChatWindowHeader_commandClose" t-att-class="{ 'o-mobile': env.messaging.device.isMobile }" t-on-click="_onClickClose" title="Close chat window">
<div class="o_ChatWindowHeader_command o_ChatWindowHeader_commandClose" t-att-class="{ 'o-mobile': chatWindow.messaging.device.isMobile }" t-on-click="_onClickClose" title="Close chat window">
<i class="fa fa-close"/>
</div>
</t>
@@ -79,10 +79,10 @@ export class Composer extends Component {
* @returns {string}
*/
get currentPartnerAvatar() {
const avatar = this.env.messaging.currentUser
const avatar = this.composer.messaging.currentUser
? this.env.session.url('/web/image', {
field: 'avatar_128',
id: this.env.messaging.currentUser.id,
id: this.composer.messaging.currentUser.id,
model: 'res.users',
})
: '/web/static/img/user_menu_avatar.png';
@@ -93,7 +93,7 @@ export class Composer extends Component {
* Focus the composer.
*/
focus() {
if (this.env.messaging.device.isMobile) {
if (this.composer.messaging.device.isMobile) {
this.el.scrollIntoView();
}
this._textInputRef.comp.focus();
@@ -67,7 +67,7 @@
class="o_Composer_textInput"
t-att-class="{
'o-composer-is-compact': props.isCompact,
'o_Composer_textInput-mobile': env.messaging.device.isMobile,
'o_Composer_textInput-mobile': composer.messaging.device.isMobile,
'o-has-current-partner-avatar': props.hasCurrentPartnerAvatar,
}"
composerLocalId="composer.localId"
@@ -80,7 +80,7 @@
t-key="composer.localId"
t-ref="textInput"
/>
<div class="o_Composer_buttons" t-att-class="{ 'o-composer-is-compact': props.isCompact, 'o-mobile': env.messaging.device.isMobile }">
<div class="o_Composer_buttons" t-att-class="{ 'o-composer-is-compact': props.isCompact, 'o-mobile': composer.messaging.device.isMobile }">
<div class="o_Composer_toolButtons"
t-att-class="{
'o-composer-has-current-partner-avatar': props.hasCurrentPartnerAvatar,
@@ -95,7 +95,7 @@
<button class="o_Composer_button o_Composer_buttonEmojis o_Composer_toolButton btn btn-light"
t-att-class="{
'o-open': false and state.displayed,
'o-mobile': env.messaging.device.isMobile,
'o-mobile': composer.messaging.device.isMobile,
}"
t-on-keydown="_onKeydownEmojiButton"
>
@@ -105,11 +105,11 @@
<EmojisPopover t-ref="emojisPopover"/>
</t>
</Popover>
<button class="o_Composer_button o_Composer_buttonAttachment o_Composer_toolButton btn btn-light fa fa-paperclip" t-att-class="{ 'o-mobile': env.messaging.device.isMobile }" title="Add attachment" type="button" t-on-click="_onClickAddAttachment"/>
<button class="o_Composer_button o_Composer_buttonAttachment o_Composer_toolButton btn btn-light fa fa-paperclip" t-att-class="{ 'o-mobile': composer.messaging.device.isMobile }" title="Add attachment" type="button" t-on-click="_onClickAddAttachment"/>
</div>
<t t-if="props.isExpandable">
<div class="o_Composer_secondaryToolButtons">
<button class="btn btn-light fa fa-expand o_Composer_button o_Composer_buttonFullComposer o_Composer_toolButton" t-att-class="{ 'o-mobile': env.messaging.device.isMobile }" title="Full composer" type="button" t-on-click="_onClickFullComposer"/>
<button class="btn btn-light fa fa-expand o_Composer_button o_Composer_buttonFullComposer o_Composer_toolButton" t-att-class="{ 'o-mobile': composer.messaging.device.isMobile }" title="Full composer" type="button" t-on-click="_onClickFullComposer"/>
</div>
</t>
</div>
@@ -149,9 +149,9 @@
<t t-if="props.hasSendButton">
<button class="o_Composer_actionButton o_Composer_button o_Composer_buttonSend btn btn-primary"
t-att-class="{
'fa': env.messaging.device.isMobile,
'fa-paper-plane-o': env.messaging.device.isMobile,
'o-last': env.messaging.device.isMobile or !props.hasDiscardButton,
'fa': composer.messaging.device.isMobile,
'fa-paper-plane-o': composer.messaging.device.isMobile,
'o-last': composer.messaging.device.isMobile or !props.hasDiscardButton,
'o-composer-is-compact': props.isCompact,
'o-has-current-partner-avatar': props.hasCurrentPartnerAvatar,
}"
@@ -159,10 +159,10 @@
type="button"
t-on-click="_onClickSend"
>
<t t-if="!env.messaging.device.isMobile"><t t-if="composer.isLog">Log</t><t t-else="">Send</t></t>
<t t-if="!composer.messaging.device.isMobile"><t t-if="composer.isLog">Log</t><t t-else="">Send</t></t>
</button>
</t>
<t t-if="!env.messaging.device.isMobile and props.hasDiscardButton">
<t t-if="!composer.messaging.device.isMobile and props.hasDiscardButton">
<button class="o_Composer_actionButton o-last o_Composer_button o_Composer_buttonDiscard btn btn-secondary" t-att-class="{ 'o-composer-is-compact': props.isCompact, 'o-has-current-partner-avatar': props.hasCurrentPartnerAvatar }" type="button" t-on-click="_onClickDiscard">
Discard
</button>
@@ -45,7 +45,7 @@ export class Discuss extends Component {
}
if (
this.discuss.thread &&
this.discuss.thread === this.env.messaging.inbox &&
this.discuss.thread === this.discuss.messaging.inbox &&
this.discuss.threadView &&
this._lastThreadCache === this.discuss.threadView.threadCache.localId &&
this._lastThreadCounter > 0 && this.discuss.thread.counter === 0
@@ -216,7 +216,7 @@ export class Discuss extends Component {
this.discuss.activeMobileNavbarTabId === 'mailbox' &&
(!this.discuss.thread || this.discuss.thread.model !== 'mailbox')
) {
this.discuss.update({ thread: link(this.env.messaging.inbox) });
this.discuss.update({ thread: link(this.discuss.messaging.inbox) });
}
if (this.discuss.activeMobileNavbarTabId !== 'mailbox') {
this.discuss.update({ thread: unlink() });
@@ -5,17 +5,17 @@
<div class="o_Discuss"
t-att-class="{
'o-adding-item': discuss ? discuss.isAddingChannel or discuss.isAddingChat : false,
'o-mobile': env.messaging ? env.messaging.device.isMobile : false,
'o-mobile': discuss and discuss.messaging ? discuss.messaging.device.isMobile : false,
}"
>
<t t-if="!env.isMessagingInitialized()">
<div class="o_Discuss_messagingNotInitialized"><i class="o_Discuss_messagingNotInitializedIcon fa fa-circle-o-notch fa-spin"/>Please wait...</div>
</t>
<t t-else="">
<t t-if="!env.messaging.device.isMobile">
<t t-if="!discuss.messaging.device.isMobile">
<DiscussSidebar class="o_Discuss_sidebar"/>
</t>
<t t-if="env.messaging.device.isMobile" t-call="mail.Discuss.content"/>
<t t-if="discuss.messaging.device.isMobile" t-call="mail.Discuss.content"/>
<t t-else="">
<div class="o_Discuss_content">
<t t-call="mail.Discuss.content"/>
@@ -26,10 +26,10 @@
</t>
<t t-name="mail.Discuss.content" owl="1">
<t t-if="env.messaging.device.isMobile and discuss.activeMobileNavbarTabId === 'mailbox'">
<t t-if="discuss.messaging.device.isMobile and discuss.activeMobileNavbarTabId === 'mailbox'">
<DiscussMobileMailboxSelection class="o_Discuss_mobileMailboxSelection border-bottom"/>
</t>
<t t-if="env.messaging.device.isMobile and (discuss.isAddingChannel or discuss.isAddingChat)">
<t t-if="discuss.messaging.device.isMobile and (discuss.isAddingChannel or discuss.isAddingChat)">
<div class="o_Discuss_mobileAddItemHeader border-bottom">
<AutocompleteInput
class="o_Discuss_mobileAddItemHeaderInput"
@@ -45,33 +45,33 @@
<t t-if="discuss.threadView">
<ThreadView
class="o_Discuss_thread"
t-att-class="{ 'o-mobile': env.messaging.device.isMobile }"
t-att-class="{ 'o-mobile': discuss.messaging.device.isMobile }"
composerAttachmentsDetailsMode="'card'"
hasComposer="discuss.thread.model !== 'mail.box'"
hasComposerCurrentPartnerAvatar="!env.messaging.device.isMobile"
hasComposerCurrentPartnerAvatar="!discuss.messaging.device.isMobile"
hasComposerThreadTyping="true"
hasSquashCloseMessages="discuss.thread.model !== 'mail.box'"
haveMessagesMarkAsReadIcon="discuss.thread === env.messaging.inbox"
haveMessagesReplyIcon="discuss.thread === env.messaging.inbox"
haveMessagesMarkAsReadIcon="discuss.thread === discuss.messaging.inbox"
haveMessagesReplyIcon="discuss.thread === discuss.messaging.inbox"
isDoFocus="discuss.isDoFocus"
threadViewLocalId="discuss.threadView.localId"
t-on-o-focusin-composer="_onFocusinComposer"
t-ref="threadView"
/>
</t>
<t t-if="!discuss.thread and (!env.messaging.device.isMobile or discuss.activeMobileNavbarTabId === 'mailbox')">
<t t-if="!discuss.thread and (!discuss.messaging.device.isMobile or discuss.activeMobileNavbarTabId === 'mailbox')">
<div class="o_Discuss_noThread">
No conversation selected.
</div>
</t>
<t t-if="env.messaging.device.isMobile and discuss.activeMobileNavbarTabId !== 'mailbox'">
<t t-if="env.messaging.discuss.activeMobileNavbarTabId === 'chat'">
<button class="o_Discuss_mobileNewChatButton btn btn-secondary" t-on-click="env.messaging.discuss.onClickMobileNewChatButton.bind(env.messaging.discuss)">
<t t-if="discuss.messaging.device.isMobile and discuss.activeMobileNavbarTabId !== 'mailbox'">
<t t-if="discuss.activeMobileNavbarTabId === 'chat'">
<button class="o_Discuss_mobileNewChatButton btn btn-secondary" t-on-click="discuss.onClickMobileNewChatButton.bind(discuss)">
Start a conversation
</button>
</t>
<t t-if="env.messaging.discuss.activeMobileNavbarTabId === 'channel'">
<button class="o_Discuss_mobileNewChannelButton btn btn-secondary" t-on-click="env.messaging.discuss.onClickMobileNewChannelButton.bind(env.messaging.discuss)">
<t t-if="discuss.activeMobileNavbarTabId === 'channel'">
<button class="o_Discuss_mobileNewChannelButton btn btn-secondary" t-on-click="discuss.onClickMobileNewChannelButton.bind(discuss)">
New Channel
</button>
</t>
@@ -80,7 +80,7 @@
filter="discuss.activeMobileNavbarTabId"
/>
</t>
<t t-if="env.messaging.device.isMobile and !discuss.isReplyingToMessage">
<t t-if="discuss.messaging.device.isMobile and !discuss.isReplyingToMessage">
<MobileMessagingNavbar
class="o_Discuss_mobileNavbar"
activeTabId="discuss.activeMobileNavbarTabId"
@@ -92,7 +92,7 @@
<Composer
class="o_Discuss_replyingToMessageComposer"
composerLocalId="discuss.replyingToMessage.originThread.composer.localId"
hasCurrentPartnerAvatar="!env.messaging.device.isMobile"
hasCurrentPartnerAvatar="!discuss.messaging.device.isMobile"
hasDiscardButton="true"
hasThreadName="true"
isDoFocus="discuss.isDoFocus"
@@ -17,16 +17,16 @@ export class DiscussMobileMailboxSelection extends Component {
return this.env.models['mail.thread']
.all(thread => thread.isPinned && thread.model === 'mail.box')
.sort((mailbox1, mailbox2) => {
if (mailbox1 === this.env.messaging.inbox) {
if (mailbox1 === this.discuss.messaging.inbox) {
return -1;
}
if (mailbox2 === this.env.messaging.inbox) {
if (mailbox2 === this.discuss.messaging.inbox) {
return 1;
}
if (mailbox1 === this.env.messaging.starred) {
if (mailbox1 === this.discuss.messaging.starred) {
return -1;
}
if (mailbox2 === this.env.messaging.starred) {
if (mailbox2 === this.discuss.messaging.starred) {
return 1;
}
const mailbox1Name = mailbox1.displayName;
@@ -52,16 +52,16 @@ export class DiscussSidebar extends Component {
return this.env.models['mail.thread']
.all(thread => thread.isPinned && thread.model === 'mail.box')
.sort((mailbox1, mailbox2) => {
if (mailbox1 === this.env.messaging.inbox) {
if (mailbox1 === this.discuss.messaging.inbox) {
return -1;
}
if (mailbox2 === this.env.messaging.inbox) {
if (mailbox2 === this.discuss.messaging.inbox) {
return 1;
}
if (mailbox1 === this.env.messaging.starred) {
if (mailbox1 === this.discuss.messaging.starred) {
return -1;
}
if (mailbox2 === this.env.messaging.starred) {
if (mailbox2 === this.discuss.messaging.starred) {
return 1;
}
const mailbox1Name = mailbox1.displayName;
@@ -119,7 +119,7 @@ export class DiscussSidebarItem extends Component {
*/
async _onClickLeave(ev) {
ev.stopPropagation();
if (this.thread.creator === this.env.messaging.currentUser) {
if (this.thread.creator === this.discuss.messaging.currentUser) {
await this._askAdminConfirmation();
}
this.thread.unsubscribe();
@@ -5,7 +5,7 @@
<div class="o_DiscussSidebarItem"
t-att-class="{
'o-active': thread and discuss.thread === thread,
'o-starred-box': thread and thread === env.messaging.starred,
'o-starred-box': thread and thread === thread.messaging.starred,
'o-unread': thread and thread.localMessageUnreadCounter > 0,
}" t-on-click="_onClick" t-att-data-thread-local-id="thread ? thread.localId : undefined" t-att-data-thread-name="thread ? thread.displayName : undefined"
>
@@ -428,7 +428,7 @@ export class Message extends Component {
*/
_onClick(ev) {
if (ev.target.closest('.o_channel_redirect')) {
this.env.messaging.openProfile({
this.message.messaging.openProfile({
id: Number(ev.target.dataset.oeId),
model: 'mail.channel',
});
@@ -438,7 +438,7 @@ export class Message extends Component {
}
if (ev.target.tagName === 'A') {
if (ev.target.dataset.oeId && ev.target.dataset.oeModel) {
this.env.messaging.openProfile({
this.message.messaging.openProfile({
id: Number(ev.target.dataset.oeId),
model: ev.target.dataset.oeModel,
});
@@ -527,7 +527,7 @@ export class Message extends Component {
// before the current handler is executed. Indeed because it does a
// toggle it needs to take into account the value before the click.
if (this._wasSelected) {
this.env.messaging.discuss.clearReplyingToMessage();
this.message.messaging.discuss.clearReplyingToMessage();
} else {
this.message.replyTo();
}
@@ -8,7 +8,7 @@
'o-discussion': message and (message.is_discussion or message.is_notification),
'o-has-message-selection': threadView and threadView.threadViewer and threadView.threadViewer.selectedMessage,
'o-highlighted': message and message.isHighlighted,
'o-mobile': env.messaging.device.isMobile,
'o-mobile': message and message.messaging.device.isMobile,
'o-not-discussion': message and !(message.is_discussion or message.is_notification),
'o-notification': message and message.message_type === 'notification',
'o-selected': isSelected,
@@ -27,7 +27,7 @@
class="o_Message_partnerImStatusIcon"
t-att-class="{
'o-message-selected': isSelected,
'o_Message_partnerImStatusIcon-mobile': env.messaging.device.isMobile,
'o_Message_partnerImStatusIcon-mobile': message.messaging.device.isMobile,
}"
hasOpenChat="hasAuthorOpenChat"
partnerLocalId="message.author.localId"
@@ -41,7 +41,7 @@
<t t-esc="shortTime"/>
</div>
</t>
<div class="o_Message_commands o_Message_sidebarCommands o_Message_sidebarItem o-message-squashed" t-att-class="{ 'o-message-selected': isSelected, 'o-mobile': env.messaging.device.isMobile }">
<div class="o_Message_commands o_Message_sidebarCommands o_Message_sidebarItem o-message-squashed" t-att-class="{ 'o-message-selected': isSelected, 'o-mobile': message.messaging.device.isMobile }">
<t t-if="message.message_type !== 'notification'">
<div class="o_Message_command o_Message_commandStar fa"
t-att-class="{
@@ -49,7 +49,7 @@
'fa-star-o': !message.isStarred,
'o-message-selected': isSelected,
'o-message-starred': message.isStarred,
'o-mobile': env.messaging.device.isMobile,
'o-mobile': message.messaging.device.isMobile,
}" t-on-click="_onClickStar"
/>
</t>
@@ -114,7 +114,7 @@
</Popover>
</t>
</t>
<div class="o_Message_commands o_Message_headerCommands" t-att-class="{ 'o-mobile': env.messaging.device.isMobile }">
<div class="o_Message_commands o_Message_headerCommands" t-att-class="{ 'o-mobile': message.messaging.device.isMobile }">
<t t-if="!message.isTemporary and ((message.message_type !== 'notification' and message.originThread and message.originThread.model === 'mail.channel') or !message.isTransient)">
<span class="o_Message_command o_Message_commandStar o_Message_headerCommand fa"
t-att-class="{
@@ -122,7 +122,7 @@
'fa-star-o': !message.isStarred,
'o-message-selected': isSelected,
'o-message-starred': message.isStarred,
'o-mobile': env.messaging.device.isMobile,
'o-mobile': message.messaging.device.isMobile,
}" t-on-click="_onClickStar" title="Mark as Todo"
/>
</t>
@@ -130,7 +130,7 @@
<span class="o_Message_command o_Message_commandReply o_Message_headerCommand fa fa-reply"
t-att-class="{
'o-message-selected': isSelected,
'o-mobile': env.messaging.device.isMobile,
'o-mobile': message.messaging.device.isMobile,
}" t-on-click="_onClickReply" title="Reply"
/>
</t>
@@ -138,7 +138,7 @@
<span class="o_Message_command o_Message_commandMarkAsRead o_Message_headerCommand fa fa-check"
t-att-class="{
'o-message-selected': isSelected,
'o-mobile': env.messaging.device.isMobile,
'o-mobile': message.messaging.device.isMobile,
}" t-on-click="_onClickMarkAsRead" title="Mark as Read"
/>
</t>
@@ -177,7 +177,7 @@
<AttachmentList
class="o_Message_attachmentList"
areAttachmentsDownloadable="true"
areAttachmentsEditable="message.author === env.messaging.currentPartner"
areAttachmentsEditable="message.author === message.messaging.currentPartner"
attachmentLocalIds="message.attachments.map(attachment => attachment.localId)"
attachmentsDetailsMode="props.attachmentsDetailsMode"
/>
@@ -4,7 +4,7 @@
<t t-name="mail.MessageAuthorPrefix" owl="1">
<span class="o_MessageAuthorPrefix">
<t t-if="message">
<t t-if="message.author and message.author === env.messaging.currentPartner">
<t t-if="message.author and message.author === message.messaging.currentPartner">
<i class="o_MessageAuthorPrefixIcon fa fa-mail-reply"/>You:
</t>
<t t-elif="thread and message.author !== thread.correspondent">
@@ -7,19 +7,19 @@
<!-- No result messages -->
<t t-if="threadView.nonEmptyMessages.length === 0">
<div class="o_MessageList_empty o_MessageList_item">
<t t-if="threadView.thread === env.messaging.inbox">
<t t-if="threadView.thread === threadView.messaging.inbox">
<div class="o_MessageList_emptyTitle">
Congratulations, your inbox is empty
</div>
New messages appear here.
</t>
<t t-elif="threadView.thread === env.messaging.starred">
<t t-elif="threadView.thread === threadView.messaging.starred">
<div class="o_MessageList_emptyTitle">
No starred messages
</div>
You can mark any message as 'starred', and it shows up in this mailbox.
</t>
<t t-elif="threadView.thread === env.messaging.history">
<t t-elif="threadView.thread === threadView.messaging.history">
<div class="o_MessageList_emptyTitle o-neutral-face-icon">
No history messages
</div>
@@ -93,12 +93,7 @@ export class MessagingMenu extends Component {
* @param {MouseEvent} ev
*/
_onClickCaptureGlobal(ev) {
if (!this.env.messaging) {
/**
* Messaging not created, which means essential models like
* messaging menu are not ready, so user interactions are omitted
* during this (short) period of time.
*/
if (!this.messagingMenu) {
return;
}
// ignore click inside the menu
@@ -122,8 +117,8 @@ export class MessagingMenu extends Component {
* @param {MouseEvent} ev
*/
_onClickNewMessage(ev) {
if (!this.env.messaging.device.isMobile) {
this.env.messaging.chatWindowManager.openNewMessage();
if (!this.messagingMenu.messaging.device.isMobile) {
this.messagingMenu.messaging.chatWindowManager.openNewMessage();
this.messagingMenu.close();
} else {
this.messagingMenu.toggleMobileNewMessage();
@@ -137,12 +132,7 @@ export class MessagingMenu extends Component {
_onClickToggler(ev) {
// avoid following dummy href
ev.preventDefault();
if (!this.env.messaging) {
/**
* Messaging not created, which means essential models like
* messaging menu are not ready, so user interactions are omitted
* during this (short) period of time.
*/
if (!this.messagingMenu) {
return;
}
this.messagingMenu.toggleOpen();
@@ -165,7 +155,7 @@ export class MessagingMenu extends Component {
* @param {integer} ui.item.id
*/
_onMobileNewMessageInputSelect(ev, ui) {
this.env.messaging.openChat({ partnerId: ui.item.id });
this.messagingMenu.messaging.openChat({ partnerId: ui.item.id });
}
/**
@@ -2,10 +2,10 @@
<templates xml:space="preserve">
<t t-name="mail.MessagingMenu" owl="1">
<li class="o_MessagingMenu" t-att-class="{ 'o-is-open': messagingMenu ? messagingMenu.isOpen : false, 'o-mobile': env.messaging ? env.messaging.device.isMobile : false }">
<li class="o_MessagingMenu" t-att-class="{ 'o-is-open': messagingMenu ? messagingMenu.isOpen : false, 'o-mobile': messagingMenu and messagingMenu.messaging ? messagingMenu.messaging.device.isMobile : false }">
<a class="o_MessagingMenu_toggler" t-att-class="{ 'o-no-notification': messagingMenu ? !messagingMenu.counter : false }" href="#" title="Conversations" role="button" t-att-aria-expanded="messagingMenu and messagingMenu.isOpen ? 'true' : 'false'" aria-haspopup="true" t-on-click="_onClickToggler">
<i class="o_MessagingMenu_icon fa fa-comments" role="img" aria-label="Messages"/>
<t t-if="!env.isMessagingInitialized()">
<t t-if="!messagingMenu or !messagingMenu.messaging.isInitialized">
<i class="o_MessagingMenu_loading fa fa-circle-o-notch fa-spin"/>
</t>
<t t-elif="messagingMenu.counter > 0">
@@ -15,13 +15,13 @@
</t>
</a>
<t t-if="messagingMenu and messagingMenu.isOpen">
<div class="o_MessagingMenu_dropdownMenu dropdown-menu dropdown-menu-right" t-att-class="{ 'o-mobile': env.messaging.device.isMobile, 'o-messaging-not-initialized': !env.messaging.isInitialized }" role="menu">
<t t-if="!env.messaging.isInitialized">
<div class="o_MessagingMenu_dropdownMenu dropdown-menu dropdown-menu-right" t-att-class="{ 'o-mobile': messagingMenu.messaging.device.isMobile, 'o-messaging-not-initialized': !messagingMenu.messaging.isInitialized }" role="menu">
<t t-if="!messagingMenu.messaging.isInitialized">
<span><i class="o_MessagingMenu_dropdownLoadingIcon fa fa-circle-o-notch fa-spin"/>Please wait...</span>
</t>
<t t-else="">
<div class="o_MessagingMenu_dropdownMenuHeader" t-att-class="{ 'o-mobile': env.messaging.device.isMobile }">
<t t-if="!env.messaging.device.isMobile">
<div class="o_MessagingMenu_dropdownMenuHeader" t-att-class="{ 'o-mobile': messagingMenu.messaging.device.isMobile }">
<t t-if="!messagingMenu.messaging.device.isMobile">
<t t-foreach="['all', 'chat', 'channel']" t-as="tabId" t-key="tabId">
<button class="o_MessagingMenu_tabButton o-desktop btn btn-link" t-att-class="{ 'o-active': messagingMenu.activeTabId === tabId, }" t-on-click="_onClickDesktopTabButton" type="button" role="tab" t-att-data-tab-id="tabId">
<t t-if="tabId === 'all'">All</t>
@@ -30,14 +30,14 @@
</button>
</t>
</t>
<t t-if="env.messaging.device.isMobile">
<t t-if="messagingMenu.messaging.device.isMobile">
<t t-call="mail.MessagingMenu.newMessageButton"/>
</t>
<div class="o-autogrow"/>
<t t-if="!env.messaging.device.isMobile and !discuss.isOpen">
<t t-if="!messagingMenu.messaging.device.isMobile and !discuss.isOpen">
<t t-call="mail.MessagingMenu.newMessageButton"/>
</t>
<t t-if="env.messaging.device.isMobile and messagingMenu.isMobileNewMessageToggled">
<t t-if="messagingMenu.messaging.device.isMobile and messagingMenu.isMobileNewMessageToggled">
<AutocompleteInput
class="o_MessagingMenu_mobileNewMessageInput"
customClass="id + '_mobileNewMessageInputAutocomplete'"
@@ -51,10 +51,10 @@
</div>
<NotificationList
class="o_MessagingMenu_notificationList"
t-att-class="{ 'o-mobile': env.messaging.device.isMobile }"
t-att-class="{ 'o-mobile': messagingMenu.messaging.device.isMobile }"
filter="messagingMenu.activeTabId"
/>
<t t-if="env.messaging.device.isMobile">
<t t-if="messagingMenu.messaging.device.isMobile">
<MobileMessagingNavbar
class="o_MessagingMenu_mobileNavbar"
activeTabId="messagingMenu.activeTabId"
@@ -71,9 +71,9 @@
<t t-name="mail.MessagingMenu.newMessageButton" owl="1">
<button class="o_MessagingMenu_newMessageButton btn"
t-att-class="{
'btn-link': !env.messaging.device.isMobile,
'btn-secondary': env.messaging.device.isMobile,
'o-mobile': env.messaging.device.isMobile,
'btn-link': !messagingMenu.messaging.device.isMobile,
'btn-secondary': messagingMenu.messaging.device.isMobile,
'o-mobile': messagingMenu.messaging.device.isMobile,
}" t-on-click="_onClickNewMessage" type="button"
>
New message
@@ -54,8 +54,8 @@ export class NotificationGroup extends Component {
return;
}
this.group.openDocuments();
if (!this.env.messaging.device.isMobile) {
this.env.messaging.messagingMenu.close();
if (!this.group.messaging.device.isMobile) {
this.group.messaging.messagingMenu.close();
}
}
@@ -65,8 +65,8 @@ export class NotificationGroup extends Component {
*/
_onClickMarkAsRead(ev) {
this.group.openCancelAction();
if (!this.env.messaging.device.isMobile) {
this.env.messaging.messagingMenu.close();
if (!this.group.messaging.device.isMobile) {
this.group.messaging.messagingMenu.close();
}
}
@@ -5,7 +5,7 @@
<span class="o_PartnerImStatusIcon fa-stack"
t-att-class="{
'o-away': partner and partner.im_status === 'away',
'o-bot': partner and env.messaging.partnerRoot === partner,
'o-bot': partner and partner.messaging.partnerRoot === partner,
'o-has-open-chat': props.hasOpenChat,
'o-offline': partner and partner.im_status === 'offline',
'o-online': partner and partner.im_status === 'online',
@@ -27,7 +27,7 @@
<t t-if="partner.im_status === 'offline'">
<i class="o_PartnerImStatusIcon_icon o-offline fa fa-circle-o fa-stack-1x" title="Offline" role="img" aria-label="User is offline"/>
</t>
<t t-if="partner === env.messaging.partnerRoot">
<t t-if="partner === partner.messaging.partnerRoot">
<i class="o_PartnerImStatusIcon_icon o-bot fa fa-heart fa-stack-1x" title="Bot" role="img" aria-label="User is a bot"/>
</t>
</t>
@@ -30,7 +30,7 @@
<t t-elif="thread.correspondent.im_status === 'away'">
<div class="o_ThreadIcon_away fa fa-circle" title="Away"/>
</t>
<t t-elif="thread.correspondent === env.messaging.partnerRoot">
<t t-elif="thread.correspondent === thread.messaging.partnerRoot">
<div class="o_ThreadIcon_online fa fa-heart" title="Bot"/>
</t>
<t t-else="" name="noImStatusCondition">
@@ -38,13 +38,13 @@
</t>
</t>
<t t-elif="thread.model === 'mail.box'">
<t t-if="thread === env.messaging.inbox">
<t t-if="thread === thread.messaging.inbox">
<div class="o_ThreadIcon_mailboxInbox fa fa-inbox"/>
</t>
<t t-elif="thread === env.messaging.starred">
<t t-elif="thread === thread.messaging.starred">
<div class="o_ThreadIcon_mailboxStarred fa fa-star-o"/>
</t>
<t t-elif="thread === env.messaging.history">
<t t-elif="thread === thread.messaging.history">
<div class="o_ThreadIcon_mailboxHistory fa fa-history"/>
</t>
</t>
@@ -77,8 +77,8 @@ export class ThreadNeedactionPreview extends Component {
return;
}
this.thread.open();
if (!this.env.messaging.device.isMobile) {
this.env.messaging.messagingMenu.close();
if (!this.thread.messaging.device.isMobile) {
this.thread.messaging.messagingMenu.close();
}
}
@@ -15,7 +15,7 @@
<PartnerImStatusIcon
class="o_ThreadNeedactionPreview_partnerImStatusIcon"
t-att-class="{
'o-mobile': env.messaging.device.isMobile,
'o-mobile': thread.messaging.device.isMobile,
}"
partnerLocalId="thread.correspondent.localId"
/>
@@ -24,7 +24,7 @@
</div>
<div class="o_ThreadNeedactionPreview_content">
<div class="o_ThreadNeedactionPreview_header">
<span class="o_ThreadNeedactionPreview_name text-truncate" t-att-class="{ 'o-mobile': env.messaging.device.isMobile }">
<span class="o_ThreadNeedactionPreview_name text-truncate" t-att-class="{ 'o-mobile': thread.messaging.device.isMobile }">
<t t-esc="thread.displayName"/>
</span>
<span class="o_ThreadNeedactionPreview_counter">
@@ -71,8 +71,8 @@ export class ThreadPreview extends Component {
return;
}
this.thread.open();
if (!this.env.messaging.device.isMobile) {
this.env.messaging.messagingMenu.close();
if (!this.thread.messaging.device.isMobile) {
this.thread.messaging.messagingMenu.close();
}
}
@@ -15,7 +15,7 @@
<PartnerImStatusIcon
class="o_ThreadPreview_partnerImStatusIcon"
t-att-class="{
'o-mobile': env.messaging.device.isMobile,
'o-mobile': thread.messaging.device.isMobile,
'o-muted': thread.localMessageUnreadCounter === 0,
}"
partnerLocalId="thread.correspondent.localId"
@@ -25,7 +25,7 @@
</div>
<div class="o_ThreadPreview_content">
<div class="o_ThreadPreview_header">
<span class="o_ThreadPreview_name text-truncate" t-att-class="{ 'o-mobile': env.messaging.device.isMobile, 'o-muted': thread.localMessageUnreadCounter === 0 }">
<span class="o_ThreadPreview_name text-truncate" t-att-class="{ 'o-mobile': thread.messaging.device.isMobile, 'o-muted': thread.localMessageUnreadCounter === 0 }">
<t t-esc="thread.displayName"/>
</span>
<t t-if="thread.localMessageUnreadCounter > 0">
@@ -31,10 +31,10 @@
</t>
</div>
<div class="o_ThreadViewTopbar_actions d-flex align-items-center">
<t t-if="threadViewTopBar.thread and threadViewTopBar.thread === env.messaging.inbox">
<t t-if="threadViewTopBar.thread and threadViewTopBar.thread === threadViewTopBar.messaging.inbox">
<button class="o_ThreadViewTopbar_markAllReadButton btn btn-secondary" t-att-disabled="threadViewTopBar.threadView.messages.length === 0" t-on-click="threadViewTopBar.onClickInboxMarkAllAsRead">Mark all read</button>
</t>
<t t-if="threadViewTopBar.thread and threadViewTopBar.thread === env.messaging.starred">
<t t-if="threadViewTopBar.thread and threadViewTopBar.thread === threadViewTopBar.messaging.starred">
<button class="o_ThreadViewTopbar_unstarAllButton btn btn-secondary" t-att-disabled="threadViewTopBar.threadView.messages.length === 0" t-on-click="threadViewTopBar.onClickUnstarAll">Unstar all</button>
</t>
<t t-if="threadViewTopBar.thread and threadViewTopBar.thread.hasInviteFeature">
@@ -36,7 +36,6 @@ function factory(dependencies) {
this.thread.notifyFoldStateToServer('closed');
}
if (this.exists()) {
// notifyFoldStateToServer() might have deleted it already
this.delete();
}
}
@@ -37,7 +37,7 @@ patch(Message.prototype, 'snailmail/static/src/components/message/message.js', {
switch (this.message.notifications[0].failure_type) {
case 'sn_credit':
// URL only used in this component, not received at init
this.env.messaging.fetchSnailmailCreditsUrl();
this.message.messaging.fetchSnailmailCreditsUrl();
this.snailmailState.hasDialog = true;
break;
case 'sn_error':
@@ -54,7 +54,7 @@ patch(Message.prototype, 'snailmail/static/src/components/message/message.js', {
break;
case 'sn_trial':
// URL only used in this component, not received at init
this.env.messaging.fetchSnailmailCreditsUrlTrial();
this.message.messaging.fetchSnailmailCreditsUrlTrial();
this.snailmailState.hasDialog = true;
break;
}
@@ -8,9 +8,9 @@
<p class="o_SnailmailErrorDialog_contentCredit">
The letter could not be sent due to insufficient credits on your IAP account.
</p>
<t t-if="env.messaging.snailmail_credits_url">
<t t-if="message.messaging.snailmail_credits_url">
<div class="text-right">
<a class="btn btn-link" t-att-href="env.messaging.snailmail_credits_url" target="_blank">
<a class="btn btn-link" t-att-href="message.messaging.snailmail_credits_url" target="_blank">
<i class="fa fa-arrow-right"/> Buy credits
</a>
</div>
@@ -20,9 +20,9 @@
<p class="o_SnailmailErrorDialog_contentTrial">
You need credits on your IAP account to send a letter.
</p>
<t t-if="env.messaging.snailmail_credits_url_trial">
<t t-if="message.messaging.snailmail_credits_url_trial">
<div class="text-right">
<a class="btn btn-link" t-att-href="env.messaging.snailmail_credits_url_trial">
<a class="btn btn-link" t-att-href="message.messaging.snailmail_credits_url_trial">
<i class="fa fa-arrow-right"/> Buy credits
</a>
</div>