diff --git a/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js b/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js index 299a5c0b046..9a05bbf6956 100644 --- a/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js +++ b/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js @@ -93,7 +93,7 @@ export class AttachmentViewer extends Component { * @private */ _handleImageLoad() { - if (!this.attachmentViewer || !this.attachmentViewer.attachment) { + if (!this.attachmentViewer.exists() || !this.attachmentViewer.attachment) { return; } const refs = this._getRefs(); @@ -213,7 +213,7 @@ export class AttachmentViewer extends Component { * @param {MouseEvent} ev */ _onClickGlobal(ev) { - if (!this.attachmentViewer) { + if (!this.attachmentViewer.exists()) { return; } if (!this.attachmentViewer.isDragging) { @@ -297,7 +297,7 @@ export class AttachmentViewer extends Component { * @param {DragEvent} ev */ _onMousedownImage(ev) { - if (!this.attachmentViewer) { + if (!this.attachmentViewer.exists()) { return; } if (this.attachmentViewer.isDragging) { @@ -317,7 +317,7 @@ export class AttachmentViewer extends Component { * @param {DragEvent} */ _onMousemoveView(ev) { - if (!this.attachmentViewer) { + if (!this.attachmentViewer.exists()) { return; } if (!this.attachmentViewer.isDragging) { diff --git a/addons/mail/static/src/components/chat_window/chat_window.js b/addons/mail/static/src/components/chat_window/chat_window.js index 2d1e560eb5c..1827651f3e3 100644 --- a/addons/mail/static/src/components/chat_window/chat_window.js +++ b/addons/mail/static/src/components/chat_window/chat_window.js @@ -41,10 +41,6 @@ export class ChatWindow extends Component { * @private */ _update() { - if (!this.chatWindow) { - // chat window is being deleted - return; - } if (!this.root.el) { return; } diff --git a/addons/mail/static/src/components/chatter/chatter.js b/addons/mail/static/src/components/chatter/chatter.js index 9f0cee635b1..500efc21cf8 100644 --- a/addons/mail/static/src/components/chatter/chatter.js +++ b/addons/mail/static/src/components/chatter/chatter.js @@ -47,9 +47,6 @@ export class Chatter extends LegacyComponent { * @private */ _update() { - if (!this.chatter) { - return; - } if (this.chatter.thread) { this._notifyRendered(); } diff --git a/addons/mail/static/src/components/composer_suggested_recipient/composer_suggested_recipient.js b/addons/mail/static/src/components/composer_suggested_recipient/composer_suggested_recipient.js index 327271f1f03..b0d289e06b6 100644 --- a/addons/mail/static/src/components/composer_suggested_recipient/composer_suggested_recipient.js +++ b/addons/mail/static/src/components/composer_suggested_recipient/composer_suggested_recipient.js @@ -83,7 +83,7 @@ export class ComposerSuggestedRecipient extends Component { * @private */ _update() { - if (this._checkboxRef.el && this.suggestedRecipientInfo) { + if (this._checkboxRef.el) { this._checkboxRef.el.checked = this.suggestedRecipientInfo.isSelected; } } @@ -116,7 +116,7 @@ export class ComposerSuggestedRecipient extends Component { * @private */ _onDialogSaved() { - const thread = this.suggestedRecipientInfo && this.suggestedRecipientInfo.thread; + const thread = this.suggestedRecipientInfo.exists() && this.suggestedRecipientInfo.thread; if (!thread) { return; } diff --git a/addons/mail/static/src/components/composer_suggestion/composer_suggestion.js b/addons/mail/static/src/components/composer_suggestion/composer_suggestion.js index 5fb96fefaeb..dda9fcd119b 100644 --- a/addons/mail/static/src/components/composer_suggestion/composer_suggestion.js +++ b/addons/mail/static/src/components/composer_suggestion/composer_suggestion.js @@ -36,8 +36,6 @@ export class ComposerSuggestion extends Component { _update() { if ( this.root.el && - this.composerSuggestion && - this.composerSuggestion.composerViewOwner && this.composerSuggestion.composerViewOwner.hasToScrollToActiveSuggestion && this.composerSuggestion.isActive ) { diff --git a/addons/mail/static/src/components/composer_text_input/composer_text_input.js b/addons/mail/static/src/components/composer_text_input/composer_text_input.js index 0e9a580b21f..25a86828d78 100644 --- a/addons/mail/static/src/components/composer_text_input/composer_text_input.js +++ b/addons/mail/static/src/components/composer_text_input/composer_text_input.js @@ -53,9 +53,6 @@ export class ComposerTextInput extends Component { * @private */ _update() { - if (!this.composerView) { - return; - } if (!this.root.el) { return; } @@ -98,7 +95,7 @@ export class ComposerTextInput extends Component { * @private */ _onInputTextarea() { - if (!this.composerView) { + if (!this.composerView.exists()) { return; } this.composerView.saveStateInStore(); diff --git a/addons/mail/static/src/components/discuss/discuss.js b/addons/mail/static/src/components/discuss/discuss.js index f8cb2b9c424..f154c4a4619 100644 --- a/addons/mail/static/src/components/discuss/discuss.js +++ b/addons/mail/static/src/components/discuss/discuss.js @@ -16,9 +16,6 @@ export class Discuss extends LegacyComponent { } _update() { - if (!this.discussView) { - return; - } if (this.discussView.discuss.thread) { this.trigger('o-push-state-action-manager'); } @@ -53,9 +50,6 @@ export class Discuss extends LegacyComponent { * @private */ _updateLocalStoreProps() { - if (!this.discussView) { - return; - } /** * Locally tracked store props `activeThreadCache`. * Useful to set scroll position from last stored one and to display diff --git a/addons/mail/static/src/components/discuss_sidebar/discuss_sidebar.js b/addons/mail/static/src/components/discuss_sidebar/discuss_sidebar.js index aa35a392a21..8b24d91f783 100644 --- a/addons/mail/static/src/components/discuss_sidebar/discuss_sidebar.js +++ b/addons/mail/static/src/components/discuss_sidebar/discuss_sidebar.js @@ -36,9 +36,6 @@ export class DiscussSidebar extends Component { * @private */ _update() { - if (!this.discussView) { - return; - } if (this.discussView.quickSearchInputRef.el) { this.discussView.quickSearchInputRef.el.value = this.discussView.discuss.sidebarQuickSearchValue; } diff --git a/addons/mail/static/src/components/message/message.js b/addons/mail/static/src/components/message/message.js index 342cfce74b8..682fed0a4a2 100644 --- a/addons/mail/static/src/components/message/message.js +++ b/addons/mail/static/src/components/message/message.js @@ -232,9 +232,6 @@ export class Message extends Component { * @private */ _update() { - if (!this.messageView) { - return; - } if (this._prettyBodyRef.el && this.messageView.message.prettyBody !== this._lastPrettyBody) { this._prettyBodyRef.el.innerHTML = this.messageView.message.prettyBody; this._lastPrettyBody = this.messageView.message.prettyBody; diff --git a/addons/mail/static/src/components/message_list/message_list.js b/addons/mail/static/src/components/message_list/message_list.js index 3d32729aae3..5a698817016 100644 --- a/addons/mail/static/src/components/message_list/message_list.js +++ b/addons/mail/static/src/components/message_list/message_list.js @@ -33,7 +33,7 @@ export class MessageList extends Component { */ this._lastRenderedValues = useRenderedValues(() => { const messageListView = this.messageListView; - const threadView = messageListView && messageListView.threadViewOwner; + const threadView = messageListView.threadViewOwner; const thread = threadView && threadView.thread; const threadCache = threadView && threadView.threadCache; return { @@ -56,12 +56,13 @@ export class MessageList extends Component { } _willPatch() { - if (!this.messageListView) { + const { messageListView } = this._lastRenderedValues(); + if (!messageListView.exists()) { return; } this._willPatchSnapshot = { - scrollHeight: this.messageListView.getScrollableElement().scrollHeight, - scrollTop: this.messageListView.getScrollableElement().scrollTop, + scrollHeight: messageListView.getScrollableElement().scrollHeight, + scrollTop: messageListView.getScrollableElement().scrollTop, }; } @@ -99,7 +100,7 @@ export class MessageList extends Component { */ adjustFromComponentHints() { const { componentHintList, messageListView } = this._lastRenderedValues(); - if (!messageListView || !messageListView.exists()) { + if (!messageListView.exists()) { return; } for (const hint of componentHintList) { @@ -223,7 +224,7 @@ export class MessageList extends Component { */ _checkMostRecentMessageIsVisible() { const { messageListView } = this._lastRenderedValues(); - if (!messageListView || !messageListView.exists()) { + if (!messageListView.exists()) { return; } const { lastMessageView } = messageListView.threadViewOwner; @@ -288,14 +289,14 @@ export class MessageList extends Component { thread, threadCache, } = this._lastRenderedValues(); - if (!messageListView || !messageListView.exists()) { + if (!messageListView.exists()) { return; } if (!messageListView.getScrollableElement()) { // could be unmounted in the meantime (due to throttled behavior) return; } - const scrollTop = this.messageListView.getScrollableElement().scrollTop; + const scrollTop = messageListView.getScrollableElement().scrollTop; this.messaging.messagingBus.trigger('o-component-message-list-scrolled', { orderedMessages, scrollTop, diff --git a/addons/mail/static/src/components/popover_view/popover_view.js b/addons/mail/static/src/components/popover_view/popover_view.js index bfacf0f542c..8d56a4468d0 100644 --- a/addons/mail/static/src/components/popover_view/popover_view.js +++ b/addons/mail/static/src/components/popover_view/popover_view.js @@ -16,7 +16,7 @@ export class PopoverView extends Component { super.setup(); useComponentToModel({ fieldName: 'component' }); usePosition( - () => this.popoverView && this.popoverView.anchorRef && this.popoverView.anchorRef.el, + () => this.popoverView.anchorRef && this.popoverView.anchorRef.el, { popper: "root", margin: 16, diff --git a/addons/mail/static/src/components/rtc_call_viewer/rtc_call_viewer.js b/addons/mail/static/src/components/rtc_call_viewer/rtc_call_viewer.js index 0f4103cec5a..6078eed62a1 100644 --- a/addons/mail/static/src/components/rtc_call_viewer/rtc_call_viewer.js +++ b/addons/mail/static/src/components/rtc_call_viewer/rtc_call_viewer.js @@ -94,9 +94,6 @@ export class RtcCallViewer extends Component { * @private */ _setTileLayout() { - if (!this.rtcCallViewer) { - return; - } if (!this.root.el) { return; } diff --git a/addons/mail/static/src/components/rtc_video/rtc_video.js b/addons/mail/static/src/components/rtc_video/rtc_video.js index b79df8a06be..753de1f0820 100644 --- a/addons/mail/static/src/components/rtc_video/rtc_video.js +++ b/addons/mail/static/src/components/rtc_video/rtc_video.js @@ -44,9 +44,6 @@ export class RtcVideo extends Component { if (!this.root.el) { return; } - if (!this.rtcVideoView) { - return; - } if (!this.rtcVideoView.rtcSession || !this.rtcVideoView.rtcSession.videoStream) { this.root.el.srcObject = undefined; } else { diff --git a/addons/mail/static/src/models/composer_suggestion.js b/addons/mail/static/src/models/composer_suggestion.js index 9e3197076bf..a48cd47ebd8 100644 --- a/addons/mail/static/src/models/composer_suggestion.js +++ b/addons/mail/static/src/models/composer_suggestion.js @@ -117,6 +117,7 @@ registerModel({ }), composerViewOwner: one('ComposerView', { compute: '_computeComposerViewOwner', + required: true, }), composerViewOwnerAsExtraSuggestion: one('ComposerView', { inverse: 'extraSuggestions',